mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::ctx: Inline interruptible(ctx, ...) manipulators.
This commit is contained in:
parent
06cf2ffa52
commit
9213d31f1d
3 changed files with 28 additions and 26 deletions
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
25
ircd/ctx.cc
25
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 &
|
||||
|
|
Loading…
Reference in a new issue