diff --git a/include/ircd/ctx/parallel.h b/include/ircd/ctx/parallel.h index b14482835..c3708b7c6 100644 --- a/include/ircd/ctx/parallel.h +++ b/include/ircd/ctx/parallel.h @@ -67,12 +67,19 @@ template void ircd::ctx::parallel::operator()(const arg &a) { - auto &p(*this->p); rethrow_any_exception(); - p(std::bind(¶llel::receiver, this)); + this->a.at(snd++) = a; snd %= this->a.size(); out++; + + auto &p(*this->p); + auto func(std::bind(¶llel::receiver, this)); + if(likely(p.size())) + p(std::move(func)); + else + func(); + wait_avail(); } @@ -81,11 +88,18 @@ void ircd::ctx::parallel::operator()() { rethrow_any_exception(); - auto &p(*this->p); - p(std::bind(¶llel::receiver, this)); + snd++; snd %= this->a.size(); out++; + + auto &p(*this->p); + auto func(std::bind(¶llel::receiver, this)); + if(likely(p.size())) + p(std::move(func)); + else + func(); + wait_avail(); }