0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::ctx: Rename function; add overload for total value.

This commit is contained in:
Jason Volk 2019-05-26 02:18:14 -07:00
parent e88f18d65c
commit 8474b891eb
4 changed files with 15 additions and 8 deletions

View file

@ -29,10 +29,10 @@ class ircd::ctx::this_ctx::critical_indicator
uint64_t state;
public:
uint64_t count() const { return yields(cur()) - state; }
operator bool() const { return yields(cur()) == state; }
uint64_t count() const { return epoch(cur()) - state; }
operator bool() const { return epoch(cur()) == state; }
critical_indicator()
:state{yields(cur())}
:state(epoch(cur()))
{}
};

View file

@ -43,14 +43,12 @@ namespace ircd::ctx
IRCD_OVERLOAD(threadsafe)
extern log::log log;
const uint64_t &id(const ctx &); // Unique ID for context
string_view name(const ctx &); // User's optional label for context
const size_t &stack_max(const ctx &); // Returns stack size allocated for ctx
const size_t &stack_at(const ctx &); // Stack at last sleep (also see this_ctx.h)
const int32_t &notes(const ctx &); // Peeks at internal semaphore count
const uint64_t &yields(const ctx &); // Context switching counter
const uint64_t &epoch(const ctx &); // Context switching counter
const ulong &cycles(const ctx &); // Accumulated tsc (not counting cur slice)
bool interruptible(const ctx &) noexcept; // Context can throw at interruption point
bool interruption(const ctx &) noexcept; // Context was marked for interruption
@ -69,6 +67,9 @@ namespace ircd::ctx
void yield(ctx &); // Direct context switch to arg
bool for_each(const std::function<bool (ctx &)> &);
const uint64_t &epoch();
extern log::log log;
}
#include "prof.h"

View file

@ -338,6 +338,12 @@ const
// ctx/ctx.h
//
const uint64_t &
ircd::ctx::epoch()
{
return prof::get(prof::event::YIELD);
}
bool
ircd::ctx::for_each(const std::function<bool (ctx &)> &closure)
{
@ -519,7 +525,7 @@ ircd::ctx::cycles(const ctx &ctx)
/// Returns the yield count for `ctx`
const uint64_t &
ircd::ctx::yields(const ctx &ctx)
ircd::ctx::epoch(const ctx &ctx)
{
return prof::get(ctx, prof::event::YIELD);
}

View file

@ -1748,7 +1748,7 @@ console_cmd__ctx__list(opt &out, const string_view &line)
;
out << " "
<< std::setw(8) << std::right << yields(ctx);
<< std::setw(8) << std::right << epoch(ctx);
out << " "
<< std::setw(5) << std::right << notes(ctx);