diff --git a/ircd/ctx.cc b/ircd/ctx.cc index a19e0f157..1a911df2b 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -52,10 +52,7 @@ noexcept try const unwind atexit([this] { mark(prof::event::CUR_LEAVE); - - if(adjoindre) - notify(*adjoindre); - + adjoindre.notify_all(); ircd::ctx::current = nullptr; this->yc = nullptr; @@ -918,9 +915,7 @@ ircd::ctx::context::join() mark(prof::event::JOIN); assert(bool(c)); - assert(!c->adjoindre); - c->adjoindre = &cur(); // Set the target context to notify this context when it finishes - wait(); + c->adjoindre.wait(); mark(prof::event::JOINED); } diff --git a/ircd/ctx.h b/ircd/ctx.h index 3ea0d4450..46bd3e582 100644 --- a/ircd/ctx.h +++ b/ircd/ctx.h @@ -48,12 +48,12 @@ struct ircd::ctx::ctx boost::asio::io_service::strand strand; // mutex/serializer boost::asio::steady_timer alarm; // acting semaphore (64B) boost::asio::yield_context *yc {nullptr}; // boost interface + continuation *cont {nullptr}; // valid when asleep; invalid when awake int64_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self ircd::ctx::stack stack; // stack related structure ircd::ctx::profile profile; // prof related structure - continuation *cont {nullptr}; // valid when asleep; invalid when awake - ctx *adjoindre {nullptr}; // context waiting for this to join() list::node node; // node for ctx::list + dock adjoindre; // contexts waiting for this to join() bool started() const { return stack.base != 0; } bool finished() const { return started() && yc == nullptr; }