From daea5cddef58eabf52ace418023ced03e932d6b3 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 16 Mar 2020 13:11:00 -0700 Subject: [PATCH] ircd::m: Replace various runlevel conditions with barrier template. --- matrix/fetch.cc | 24 ++++-------------------- matrix/init_backfill.cc | 6 ++---- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/matrix/fetch.cc b/matrix/fetch.cc index 3488c2582..c7f20fc8c 100644 --- a/matrix/fetch.cc +++ b/matrix/fetch.cc @@ -118,32 +118,16 @@ noexcept // // -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::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 + { + "The fetch unit is unavailable to start requests." + }; // in case the fetch unit has reached capacity the context will yield. dock.wait([] diff --git a/matrix/init_backfill.cc b/matrix/init_backfill.cc index dbd55922f..fee5e14ca 100644 --- a/matrix/init_backfill.cc +++ b/matrix/init_backfill.cc @@ -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{}; // Set a low priority for this context; see related pool_opts ionice(ctx::cur(), 4);