0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-23 21:33:44 +02:00

ircd:Ⓜ️ Replace various runlevel conditions with barrier template.

This commit is contained in:
Jason Volk 2020-03-16 13:11:00 -07:00
parent c3b709dbd7
commit daea5cddef
2 changed files with 6 additions and 24 deletions

View file

@ -118,32 +118,16 @@ noexcept
// <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::m::fetch::start(opts opts)
{
assert(opts.room_id && opts.event_id);
// 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.
dock.wait([]

View file

@ -109,10 +109,8 @@ void
ircd::m::init::backfill::worker()
try
{
run::changed::dock.wait([]
{
return run::level == run::level::RUN;
});
// Wait for runlevel RUN before proceeding...
run::barrier<ctx::interrupted>{};
// Set a low priority for this context; see related pool_opts
ionice(ctx::cur(), 4);