mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::ctx: Add pool::set convenience.
This commit is contained in:
parent
ea172a3378
commit
6cdb1bba63
3 changed files with 12 additions and 2 deletions
|
@ -71,7 +71,7 @@ struct ircd::conf::item<void>
|
|||
string_view get(const mutable_buffer &) const;
|
||||
bool set(const string_view &);
|
||||
|
||||
item(const json::members &, conf::set_cb = {});
|
||||
item(const json::members &, conf::set_cb);
|
||||
item(item &&) = delete;
|
||||
item(const item &) = delete;
|
||||
virtual ~item() noexcept;
|
||||
|
|
|
@ -43,6 +43,7 @@ struct ircd::ctx::pool
|
|||
// control panel
|
||||
void add(const size_t & = 1);
|
||||
void del(const size_t & = 1);
|
||||
void set(const size_t &);
|
||||
void terminate();
|
||||
void interrupt();
|
||||
void join();
|
||||
|
|
11
ircd/ctx.cc
11
ircd/ctx.cc
|
@ -1010,6 +1010,15 @@ ircd::ctx::pool::operator()(closure closure)
|
|||
dock.notify();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::ctx::pool::set(const size_t &num)
|
||||
{
|
||||
if(size() > num)
|
||||
del(size() - num);
|
||||
else
|
||||
add(num - size());
|
||||
}
|
||||
|
||||
void
|
||||
ircd::ctx::pool::del(const size_t &num)
|
||||
{
|
||||
|
@ -1037,7 +1046,7 @@ ircd::ctx::pool::add(const size_t &num)
|
|||
void
|
||||
ircd::ctx::pool::join()
|
||||
{
|
||||
del(size());
|
||||
set(0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue