mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 18:18:56 +02:00
ircd::ctx: Minor cleanup; tweak promise union; noexcept and linkage for ctors.
This commit is contained in:
parent
592181a09f
commit
0a4cfc59be
|
@ -46,10 +46,9 @@ struct ircd::ctx::promise_base
|
|||
// Internal operations
|
||||
static const promise_base *head(const shared_state_base &);
|
||||
static const promise_base *head(const promise_base &);
|
||||
static size_t refcount(const shared_state_base &);
|
||||
|
||||
static promise_base *head(promise_base &);
|
||||
static promise_base *head(shared_state_base &);
|
||||
static promise_base *head(promise_base &);
|
||||
static size_t refcount(const shared_state_base &);
|
||||
|
||||
shared_state_base *st {nullptr}; // the head of all sharing futures
|
||||
promise_base *next {nullptr}; // next sharing promise
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace ircd::ctx
|
|||
IRCD_EXCEPTION(ircd::ctx::error, future_error)
|
||||
IRCD_OVERLOAD(already)
|
||||
|
||||
future_state state(const shared_state_base &);
|
||||
bool is(const shared_state_base &, const future_state &);
|
||||
future_state state(const shared_state_base &) noexcept;
|
||||
bool is(const shared_state_base &, const future_state &) noexcept;
|
||||
void set(shared_state_base &, const future_state &);
|
||||
}
|
||||
|
||||
|
@ -71,14 +71,14 @@ struct ircd::ctx::shared_state_base
|
|||
std::exception_ptr eptr;
|
||||
std::function<void (shared_state_base &)> then;
|
||||
shared_state_base *next{nullptr}; // next sharing future
|
||||
union
|
||||
union alignas(8)
|
||||
{
|
||||
promise_base *p {nullptr}; // the head of all sharing promises
|
||||
future_state st;
|
||||
promise_base *p; // the head of all sharing promises
|
||||
future_state st {future_state::INVALID};
|
||||
};
|
||||
|
||||
shared_state_base() = default;
|
||||
shared_state_base(already_t);
|
||||
shared_state_base() noexcept;
|
||||
shared_state_base(already_t) noexcept;
|
||||
shared_state_base(promise_base &);
|
||||
shared_state_base(shared_state_base &&) noexcept;
|
||||
shared_state_base(const shared_state_base &);
|
||||
|
|
|
@ -2250,6 +2250,7 @@ ircd::ctx::set(shared_state_base &st,
|
|||
bool
|
||||
ircd::ctx::is(const shared_state_base &st,
|
||||
const future_state &state_)
|
||||
noexcept
|
||||
{
|
||||
switch(st.st)
|
||||
{
|
||||
|
@ -2286,6 +2287,7 @@ ircd::ctx::is(const shared_state_base &st,
|
|||
/// above the few low-numbered enum values.
|
||||
ircd::ctx::future_state
|
||||
ircd::ctx::state(const shared_state_base &st)
|
||||
noexcept
|
||||
{
|
||||
return uintptr_t(st.p) >= ircd::info::page_size?
|
||||
future_state::PENDING:
|
||||
|
@ -2296,7 +2298,13 @@ ircd::ctx::state(const shared_state_base &st)
|
|||
// shared_state_base::shared_state_base
|
||||
//
|
||||
|
||||
ircd::ctx::shared_state_base::shared_state_base()
|
||||
noexcept
|
||||
{
|
||||
}
|
||||
|
||||
ircd::ctx::shared_state_base::shared_state_base(already_t)
|
||||
noexcept
|
||||
{
|
||||
set(*this, future_state::READY);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue