mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd::ctx::pool: Add a terminate(); cleanup del().
This commit is contained in:
parent
32c0d08928
commit
f4a4674daa
2 changed files with 19 additions and 2 deletions
|
@ -43,6 +43,7 @@ struct ircd::ctx::pool
|
|||
// control panel
|
||||
void add(const size_t & = 1);
|
||||
void del(const size_t & = 1);
|
||||
void terminate();
|
||||
void interrupt();
|
||||
void join();
|
||||
|
||||
|
|
20
ircd/ctx.cc
20
ircd/ctx.cc
|
@ -969,11 +969,20 @@ ircd::ctx::pool::operator()(closure closure)
|
|||
void
|
||||
ircd::ctx::pool::del(const size_t &num)
|
||||
{
|
||||
const ssize_t requested(size() - num);
|
||||
const size_t target(std::max(requested, ssize_t(0)));
|
||||
const auto requested
|
||||
{
|
||||
ssize_t(size()) - ssize_t(num)
|
||||
};
|
||||
|
||||
const auto target
|
||||
{
|
||||
size_t(std::max(requested, 0L))
|
||||
};
|
||||
|
||||
for(size_t i(target); i < ctxs.size(); ++i)
|
||||
ctxs.at(i).terminate();
|
||||
|
||||
const uninterruptible ui;
|
||||
while(ctxs.size() > target)
|
||||
ctxs.pop_back();
|
||||
}
|
||||
|
@ -998,6 +1007,13 @@ ircd::ctx::pool::interrupt()
|
|||
context.interrupt();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::ctx::pool::terminate()
|
||||
{
|
||||
for(auto &context : ctxs)
|
||||
context.terminate();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::ctx::pool::main()
|
||||
noexcept try
|
||||
|
|
Loading…
Add table
Reference in a new issue