mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd:Ⓜ️ Replace various runlevel conditions with barrier template.
This commit is contained in:
parent
c3b709dbd7
commit
daea5cddef
2 changed files with 6 additions and 24 deletions
|
@ -118,32 +118,16 @@ noexcept
|
||||||
// <ircd/m/fetch.h>
|
// <ircd/m/fetch.h>
|
||||||
//
|
//
|
||||||
|
|
||||||
static void
|
|
||||||
wait_for_run()
|
|
||||||
{
|
|
||||||
using namespace ircd::run;
|
|
||||||
using namespace ircd;
|
|
||||||
|
|
||||||
changed::dock.wait([]
|
|
||||||
{
|
|
||||||
return level == level::RUN || level == level::QUIT;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(unlikely(level != level::RUN))
|
|
||||||
throw m::UNAVAILABLE
|
|
||||||
{
|
|
||||||
"Cannot fetch in runlevel '%s'",
|
|
||||||
reflect(level)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ircd::ctx::future<ircd::m::fetch::result>
|
ircd::ctx::future<ircd::m::fetch::result>
|
||||||
ircd::m::fetch::start(opts opts)
|
ircd::m::fetch::start(opts opts)
|
||||||
{
|
{
|
||||||
assert(opts.room_id && opts.event_id);
|
assert(opts.room_id && opts.event_id);
|
||||||
|
|
||||||
// in case requests are started before runlevel RUN they are stalled here
|
// in case requests are started before runlevel RUN they are stalled here
|
||||||
wait_for_run();
|
run::barrier<m::UNAVAILABLE>
|
||||||
|
{
|
||||||
|
"The fetch unit is unavailable to start requests."
|
||||||
|
};
|
||||||
|
|
||||||
// in case the fetch unit has reached capacity the context will yield.
|
// in case the fetch unit has reached capacity the context will yield.
|
||||||
dock.wait([]
|
dock.wait([]
|
||||||
|
|
|
@ -109,10 +109,8 @@ void
|
||||||
ircd::m::init::backfill::worker()
|
ircd::m::init::backfill::worker()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
run::changed::dock.wait([]
|
// Wait for runlevel RUN before proceeding...
|
||||||
{
|
run::barrier<ctx::interrupted>{};
|
||||||
return run::level == run::level::RUN;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set a low priority for this context; see related pool_opts
|
// Set a low priority for this context; see related pool_opts
|
||||||
ionice(ctx::cur(), 4);
|
ionice(ctx::cur(), 4);
|
||||||
|
|
Loading…
Reference in a new issue