0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-14 00:34:18 +01:00

ircd::ctx: Improve the pool counters.

This commit is contained in:
Jason Volk 2017-11-25 19:21:21 -07:00
parent a046a56d0d
commit ae289de529
2 changed files with 10 additions and 8 deletions

View file

@ -34,7 +34,8 @@ struct ircd::ctx::pool
private:
const char *name;
size_t stack_size;
size_t available;
size_t running;
size_t working;
struct dock dock;
std::deque<closure> queue;
std::vector<context> ctxs;
@ -45,9 +46,9 @@ struct ircd::ctx::pool
public:
// indicators
auto size() const { return ctxs.size(); }
auto avail() const { return available; }
auto queued() const { return queue.size(); }
auto active() const { return size() - avail(); }
auto active() const { return working; }
auto avail() const { return running - working; }
auto pending() const { return active() + queued(); }
// control panel

View file

@ -678,7 +678,8 @@ ircd::ctx::pool::pool(const char *const &name,
const size_t &size)
:name{name}
,stack_size{stack_size}
,available{0}
,running{0}
,working{0}
{
add(size);
}
@ -729,10 +730,10 @@ void
ircd::ctx::pool::main()
try
{
++available;
++running;
const unwind avail([this]
{
--available;
--running;
});
while(1)
@ -755,10 +756,10 @@ try
return !queue.empty();
});
--available;
++working;
const unwind avail([this]
{
++available;
--working;
});
const auto func(std::move(queue.front()));