diff --git a/include/ircd/ctx/ctx.h b/include/ircd/ctx/ctx.h index fd7e53dec..0e1c6d456 100644 --- a/include/ircd/ctx/ctx.h +++ b/include/ircd/ctx/ctx.h @@ -81,6 +81,7 @@ namespace ircd::ctx #include "prof.h" #include "this_ctx.h" +#include "context.h" #include "wait.h" #include "sleep.h" #include "stack.h" @@ -105,7 +106,6 @@ namespace ircd::ctx #include "promise.h" #include "future.h" #include "when.h" -#include "context.h" #include "async.h" #include "pool.h" #include "ole.h" diff --git a/include/ircd/ctx/uninterruptible.h b/include/ircd/ctx/uninterruptible.h index cc374fff6..f2e9f5d3c 100644 --- a/include/ircd/ctx/uninterruptible.h +++ b/include/ircd/ctx/uninterruptible.h @@ -11,6 +11,12 @@ #pragma once #define HAVE_IRCD_CTX_UNINTERRUPTIBLE_H +namespace ircd::ctx +{ + bool interruptible(const ctx &) noexcept; + void interruptible(ctx &, const bool &) noexcept; +} + namespace ircd::ctx { inline namespace this_ctx { @@ -114,3 +120,24 @@ noexcept { return interruptible(cur()); } + +/// Marks `ctx` for whether to allow or suppress interruption. Suppression +/// does not ignore an interrupt itself, it only ignores the interruption +/// points. Thus when a suppression ends if the interrupt flag was ever set +/// the next interruption point will throw as expected. +inline void +ircd::ctx::interruptible(ctx &ctx, + const bool &b) +noexcept +{ + flags(ctx) ^= (flags(ctx) ^ (ulong(b) - 1)) & context::NOINTERRUPT; + assert(bool(flags(ctx) & context::NOINTERRUPT) == !b); + assert(interruptible(ctx) == b); +} + +inline bool +ircd::ctx::interruptible(const ctx &ctx) +noexcept +{ + return ~flags(ctx) & context::NOINTERRUPT; +} diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 8522faacf..0b0ab940b 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -506,22 +506,6 @@ ircd::ctx::interrupt(ctx &ctx) (*ctx.cont->intr)(current); } -/// Marks `ctx` for whether to allow or suppress interruption. Suppression -/// does not ignore an interrupt itself, it only ignores the interruption -/// points. Thus when a suppression ends if the interrupt flag was ever set -/// the next interruption point will throw as expected. -[[gnu::hot]] -void -ircd::ctx::interruptible(ctx &ctx, - const bool &b) -noexcept -{ - if(b) - ctx.flags &= ~context::NOINTERRUPT; - else - ctx.flags |= context::NOINTERRUPT; -} - int8_t ircd::ctx::nice(ctx &ctx, const int8_t &val) @@ -612,15 +596,6 @@ noexcept return c.flags & context::INTERRUPTED; } -/// Indicates if `ctx` will suppress any interrupts. -[[gnu::hot]] -bool -ircd::ctx::interruptible(const ctx &c) -noexcept -{ - return ~c.flags & context::NOINTERRUPT; -} - /// Returns the cycle count for `ctx` [[gnu::hot]] const ulong &