0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 13:18:58 +02:00

ircd::ctx::parallel: Handle case for empty pool by executing receiver immediately.

This commit is contained in:
Jason Volk 2019-01-01 20:29:59 -08:00
parent c2103ec0d6
commit 7f4bb1a7db

View file

@ -67,12 +67,19 @@ template<class arg>
void void
ircd::ctx::parallel<arg>::operator()(const arg &a) ircd::ctx::parallel<arg>::operator()(const arg &a)
{ {
auto &p(*this->p);
rethrow_any_exception(); rethrow_any_exception();
p(std::bind(&parallel::receiver, this));
this->a.at(snd++) = a; this->a.at(snd++) = a;
snd %= this->a.size(); snd %= this->a.size();
out++; out++;
auto &p(*this->p);
auto func(std::bind(&parallel::receiver, this));
if(likely(p.size()))
p(std::move(func));
else
func();
wait_avail(); wait_avail();
} }
@ -81,11 +88,18 @@ void
ircd::ctx::parallel<arg>::operator()() ircd::ctx::parallel<arg>::operator()()
{ {
rethrow_any_exception(); rethrow_any_exception();
auto &p(*this->p);
p(std::bind(&parallel::receiver, this));
snd++; snd++;
snd %= this->a.size(); snd %= this->a.size();
out++; out++;
auto &p(*this->p);
auto func(std::bind(&parallel::receiver, this));
if(likely(p.size()))
p(std::move(func));
else
func();
wait_avail(); wait_avail();
} }