0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::ctx::pool: Use ctx::queue for pool's queue.

This commit is contained in:
Jason Volk 2018-09-18 16:45:04 -07:00
parent a66c312c92
commit 5698637dd6
2 changed files with 7 additions and 11 deletions

View file

@ -25,8 +25,7 @@ struct ircd::ctx::pool
size_t stack_size;
size_t running;
size_t working;
struct dock dock;
std::deque<closure> queue;
queue<closure> q;
std::vector<context> ctxs;
void next();
@ -35,7 +34,7 @@ struct ircd::ctx::pool
public:
// indicators
auto size() const { return ctxs.size(); }
auto queued() const { return queue.size(); }
auto queued() const { return q.size(); }
auto active() const { return working; }
auto avail() const { return running - working; }
auto pending() const { return active() + queued(); }

View file

@ -1024,14 +1024,13 @@ noexcept
join();
assert(ctxs.empty());
assert(queue.empty());
assert(q.empty());
}
void
ircd::ctx::pool::operator()(closure closure)
{
queue.push_back(std::move(closure));
dock.notify();
q.emplace(std::move(closure));
}
void
@ -1119,10 +1118,10 @@ void
ircd::ctx::pool::next()
try
{
dock.wait([this]
const auto func
{
return !queue.empty();
});
std::move(q.pop())
};
++working;
const unwind avail([this]
@ -1130,8 +1129,6 @@ try
--working;
});
const auto func(std::move(queue.front()));
queue.pop_front();
func();
}
catch(const interrupted &e)