mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +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;
|
string_view get(const mutable_buffer &) const;
|
||||||
bool set(const string_view &);
|
bool set(const string_view &);
|
||||||
|
|
||||||
item(const json::members &, conf::set_cb = {});
|
item(const json::members &, conf::set_cb);
|
||||||
item(item &&) = delete;
|
item(item &&) = delete;
|
||||||
item(const item &) = delete;
|
item(const item &) = delete;
|
||||||
virtual ~item() noexcept;
|
virtual ~item() noexcept;
|
||||||
|
|
|
@ -43,6 +43,7 @@ struct ircd::ctx::pool
|
||||||
// control panel
|
// control panel
|
||||||
void add(const size_t & = 1);
|
void add(const size_t & = 1);
|
||||||
void del(const size_t & = 1);
|
void del(const size_t & = 1);
|
||||||
|
void set(const size_t &);
|
||||||
void terminate();
|
void terminate();
|
||||||
void interrupt();
|
void interrupt();
|
||||||
void join();
|
void join();
|
||||||
|
|
11
ircd/ctx.cc
11
ircd/ctx.cc
|
@ -1010,6 +1010,15 @@ ircd::ctx::pool::operator()(closure closure)
|
||||||
dock.notify();
|
dock.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::ctx::pool::set(const size_t &num)
|
||||||
|
{
|
||||||
|
if(size() > num)
|
||||||
|
del(size() - num);
|
||||||
|
else
|
||||||
|
add(num - size());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::ctx::pool::del(const size_t &num)
|
ircd::ctx::pool::del(const size_t &num)
|
||||||
{
|
{
|
||||||
|
@ -1037,7 +1046,7 @@ ircd::ctx::pool::add(const size_t &num)
|
||||||
void
|
void
|
||||||
ircd::ctx::pool::join()
|
ircd::ctx::pool::join()
|
||||||
{
|
{
|
||||||
del(size());
|
set(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue