0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-01 08:18:20 +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
ircd::ctx::parallel<arg>::operator()(const arg &a)
{
auto &p(*this->p);
rethrow_any_exception();
p(std::bind(&parallel::receiver, this));
this->a.at(snd++) = a;
snd %= this->a.size();
out++;
auto &p(*this->p);
auto func(std::bind(&parallel::receiver, this));
if(likely(p.size()))
p(std::move(func));
else
func();
wait_avail();
}
@ -81,11 +88,18 @@ void
ircd::ctx::parallel<arg>::operator()()
{
rethrow_any_exception();
auto &p(*this->p);
p(std::bind(&parallel::receiver, this));
snd++;
snd %= this->a.size();
out++;
auto &p(*this->p);
auto func(std::bind(&parallel::receiver, this));
if(likely(p.size()))
p(std::move(func));
else
func();
wait_avail();
}