From 00fe4baa2ac9f904b96dbe809d00fd341cf7808a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 18 May 2020 19:04:31 -0700 Subject: [PATCH] ircd::ctx: Add direct flags reference accessor to interface. --- include/ircd/ctx/context.h | 4 ++-- include/ircd/ctx/ctx.h | 2 ++ ircd/ctx.cc | 18 ++++++++++++++++++ ircd/ctx.h | 4 +++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/ircd/ctx/context.h b/include/ircd/ctx/context.h index 3824e4706..6bca9b0fa 100644 --- a/include/ircd/ctx/context.h +++ b/include/ircd/ctx/context.h @@ -44,7 +44,7 @@ namespace ircd::ctx /// struct ircd::ctx::context { - enum flags :uint; + enum flags :uint32_t; using function = std::function; private: @@ -96,7 +96,7 @@ struct ircd::ctx::context }; enum ircd::ctx::context::flags -:uint +:uint32_t { POST = 0x0001, ///< Defers spawn with an ios.post() DISPATCH = 0x0002, ///< Defers spawn with an ios.dispatch() diff --git a/include/ircd/ctx/ctx.h b/include/ircd/ctx/ctx.h index 135291ada..c6fcb2773 100644 --- a/include/ircd/ctx/ctx.h +++ b/include/ircd/ctx/ctx.h @@ -47,6 +47,7 @@ namespace ircd::ctx const uint64_t &id(const ctx &) noexcept; // Unique ID for context string_view name(const ctx &) noexcept; // User's optional label for context + const uint32_t &flags(const ctx &) noexcept; // Direct flags access const int32_t ¬es(const ctx &) noexcept; // Peeks at internal semaphore count const uint64_t &epoch(const ctx &) noexcept; // Context switching counter const ulong &cycles(const ctx &) noexcept; // Accumulated tsc (not counting cur slice) @@ -61,6 +62,7 @@ namespace ircd::ctx bool waiting(const ctx &) noexcept; // started() && !finished() && !running() bool queued(const ctx &) noexcept; // !running() && notes() > 0 + uint32_t &flags(ctx &) noexcept; // Direct flags access int8_t ionice(ctx &, const int8_t &); // IO priority nice-value int8_t nice(ctx &, const int8_t &); // Scheduling priority nice-value void interruptible(ctx &, const bool &); // False for interrupt suppression. diff --git a/ircd/ctx.cc b/ircd/ctx.cc index cdbf04d4f..6a015df74 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -537,6 +537,15 @@ ircd::ctx::ionice(ctx &ctx, return ctx.ionice; } +/// Returns writable reference to the flags of ctx +[[gnu::hot]] +uint32_t & +ircd::ctx::flags(ctx &ctx) +noexcept +{ + return ctx.flags; +} + /// !running() && notes > 0 [[gnu::hot]] bool @@ -654,6 +663,15 @@ noexcept return ctx.notes; } +/// Returns reference to the flags of ctx +[[gnu::hot]] +const uint32_t & +ircd::ctx::flags(const ctx &ctx) +noexcept +{ + return ctx.flags; +} + /// Returns the developer's optional name literal for `ctx` [[gnu::hot]] ircd::string_view diff --git a/ircd/ctx.h b/ircd/ctx.h index e5b7ec67c..066f11d31 100644 --- a/ircd/ctx.h +++ b/ircd/ctx.h @@ -28,12 +28,14 @@ namespace ircd::ctx::prof struct ircd::ctx::ctx :instance_list { + using flags_type = std::underlying_type::type; + static uint64_t id_ctr; // monotonic static ios::descriptor ios_desc; uint64_t id {++id_ctr}; // Unique runtime ID string_view name; // User given name (optional) - context::flags flags; // User given flags + flags_type flags; // User given flags int8_t nice {0}; // Scheduling priority nice-value int8_t ionice {0}; // IO priority nice-value (defaults for fs::opts) int32_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self