mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::ctx: Use dock for better adjoindre semantics.
This commit is contained in:
parent
f68f3bbb9c
commit
956c67beca
2 changed files with 4 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue