mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 01:30:12 +01:00
ircd::ctx::parallel: Handle case for empty pool by executing receiver immediately.
This commit is contained in:
parent
c2103ec0d6
commit
7f4bb1a7db
1 changed files with 18 additions and 4 deletions
|
@ -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(¶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<arg>::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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue