mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
ircd::ctx: Move resume-interruption point to this_ctx::wait() suite.
This commit is contained in:
parent
7c24e6dab6
commit
9d7a53ae49
2 changed files with 6 additions and 9 deletions
|
@ -75,7 +75,7 @@ struct ircd::ctx::continuation
|
|||
continuation(const predicate & = true_predicate,
|
||||
const interruptor & = noop_interruptor);
|
||||
|
||||
~continuation() noexcept(false);
|
||||
~continuation() noexcept;
|
||||
};
|
||||
|
||||
/// This type of continuation should be used when yielding a context to a
|
||||
|
@ -92,5 +92,5 @@ struct ircd::ctx::to_asio
|
|||
{
|
||||
to_asio() = default;
|
||||
to_asio(const interruptor &);
|
||||
~to_asio() noexcept(false) = default;
|
||||
~to_asio() noexcept = default;
|
||||
};
|
||||
|
|
11
ircd/ctx.cc
11
ircd/ctx.cc
|
@ -544,7 +544,7 @@ ircd::ctx::this_ctx::wait_until(const steady_clock::time_point &tp,
|
|||
auto &c(cur());
|
||||
c.alarm.expires_at(tp);
|
||||
c.wait(); // now you're yielding with portals
|
||||
|
||||
c.interruption_point();
|
||||
return steady_clock::now() >= tp;
|
||||
}
|
||||
|
||||
|
@ -559,6 +559,7 @@ ircd::ctx::this_ctx::wait(const microseconds &duration,
|
|||
auto &c(cur());
|
||||
c.alarm.expires_from_now(duration);
|
||||
c.wait(); // now you're yielding with portals
|
||||
c.interruption_point();
|
||||
const auto ret(c.alarm.expires_from_now());
|
||||
|
||||
// return remaining duration.
|
||||
|
@ -574,6 +575,7 @@ ircd::ctx::this_ctx::wait()
|
|||
auto &c(cur());
|
||||
c.alarm.expires_at(steady_clock::time_point::max());
|
||||
c.wait(); // now you're yielding with portals
|
||||
c.interruption_point();
|
||||
}
|
||||
|
||||
/// Post the currently running context to the event queue and then suspend to
|
||||
|
@ -962,7 +964,7 @@ ircd::ctx::continuation::continuation(const predicate &pred,
|
|||
}
|
||||
|
||||
ircd::ctx::continuation::~continuation()
|
||||
noexcept(false)
|
||||
noexcept
|
||||
{
|
||||
// Set the fundamental current context register as the first operation
|
||||
// upon resuming execution.
|
||||
|
@ -975,11 +977,6 @@ noexcept(false)
|
|||
// Unconditionally reset the notes counter to 1 because we're awake now.
|
||||
self->notes = 1;
|
||||
|
||||
// Check here if this context's interrupt flag is set. If so, this call
|
||||
// will clear the flag and then throw an exception. Note that this is
|
||||
// a destructor with exceptions permitted to come out of it.
|
||||
self->interruption_point();
|
||||
|
||||
// self->continuation is not null'ed here; it remains an invalid
|
||||
// pointer while the context is awake.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue