#include <exec_ctx.h>
Classes | |
struct | CombinerData |
Public Member Functions | |
grpc_closure_list * | closure_list () |
CombinerData * | combiner_data () |
ExecCtx () | |
ExecCtx (const ExecCtx &)=delete | |
ExecCtx (uintptr_t fl) | |
uintptr_t | flags () |
bool | Flush () |
bool | HasWork () |
void | InvalidateNow () |
bool | IsReadyToFinish () |
Timestamp | Now () |
ExecCtx & | operator= (const ExecCtx &)=delete |
void | SetNowIomgrShutdown () |
unsigned | starting_cpu () |
void | TestOnlySetNow (Timestamp new_val) |
virtual | ~ExecCtx () |
Static Public Member Functions | |
static ExecCtx * | Get () |
static void | Run (const DebugLocation &location, grpc_closure *closure, grpc_error_handle error) |
static void | RunList (const DebugLocation &location, grpc_closure_list *list) |
Protected Member Functions | |
virtual bool | CheckReadyToFinish () |
Static Protected Member Functions | |
static void | operator delete (void *) |
Static Private Member Functions | |
static | GPR_THREAD_LOCAL (ExecCtx *) exec_ctx_ |
static void | Set (ExecCtx *exec_ctx) |
Private Attributes | |
grpc_closure_list | closure_list_ = GRPC_CLOSURE_LIST_INIT |
CombinerData | combiner_data_ = {nullptr, nullptr} |
uintptr_t | flags_ |
ExecCtx * | last_exec_ctx_ = Get() |
Timestamp | now_ |
bool | now_is_valid_ = false |
unsigned | starting_cpu_ = std::numeric_limits<unsigned>::max() |
Execution context. A bag of data that collects information along a callstack. It is created on the stack at core entry points (public API or iomgr), and stored internally as a thread-local variable.
Generally, to create an exec_ctx instance, add the following line at the top of the public API entry point or at the start of a thread's work function :
ExecCtx exec_ctx;
Access the created ExecCtx instance using : ExecCtx::Get()
Specific responsibilities (this may grow in the future):
CONVENTIONS:
TODO(yashykt): Only allow one "active" ExecCtx on a thread at the same time. Stage 1: If a new one is created on the stack, it should just pass-through to the underlying ExecCtx deeper in the thread's stack. Stage 2: Assert if a 2nd one is ever created on the stack since that implies a core re-entry outside of application callbacks.
Definition at line 97 of file exec_ctx.h.
|
inline |
Default Constructor
Definition at line 101 of file exec_ctx.h.
|
inlineexplicit |
Parameterised Constructor
Definition at line 107 of file exec_ctx.h.
|
inlinevirtual |
Destructor
Definition at line 115 of file exec_ctx.h.
|
inlineprotectedvirtual |
Check if ready to finish.
Reimplemented in ExecCtxPluck, and ExecCtxNext.
Definition at line 214 of file exec_ctx.h.
|
inline |
Return pointer to grpc_closure_list
Definition at line 146 of file exec_ctx.h.
|
inline |
Only to be used by grpc-combiner code
Definition at line 143 of file exec_ctx.h.
|
inline |
Return flags
Definition at line 149 of file exec_ctx.h.
bool grpc_core::ExecCtx::Flush | ( | ) |
Flush any work that has been enqueued onto this grpc_exec_ctx. Caller must guarantee that no interfering locks are held. Returns true if work was performed, false otherwise.
Definition at line 69 of file exec_ctx.cc.
|
inlinestatic |
Gets pointer to current exec_ctx.
Definition at line 205 of file exec_ctx.h.
|
staticprivate |
|
inline |
Checks if there is work to be done
Definition at line 152 of file exec_ctx.h.
|
inline |
Invalidates the stored time value. A new time value will be set on calling Now().
Definition at line 188 of file exec_ctx.h.
|
inline |
Returns true if we'd like to leave this execution context as soon as possible: useful for deciding whether to do something more or not depending on outside context.
Definition at line 167 of file exec_ctx.h.
Timestamp grpc_core::ExecCtx::Now | ( | ) |
Returns the stored current time relative to start if valid, otherwise refreshes the stored time, sets it valid and returns the new value.
Definition at line 90 of file exec_ctx.cc.
|
inlinestaticprotected |
Disallow delete on ExecCtx.
Definition at line 217 of file exec_ctx.h.
|
static |
Definition at line 98 of file exec_ctx.cc.
|
static |
Definition at line 129 of file exec_ctx.cc.
|
inlinestaticprivate |
Set exec_ctx_ to exec_ctx.
Definition at line 221 of file exec_ctx.h.
|
inline |
To be used only by shutdown code in iomgr
Definition at line 191 of file exec_ctx.h.
|
inline |
Definition at line 128 of file exec_ctx.h.
|
inline |
To be used only for testing. Sets the now value.
Definition at line 199 of file exec_ctx.h.
|
private |
Definition at line 223 of file exec_ctx.h.
|
private |
Definition at line 224 of file exec_ctx.h.
|
private |
Definition at line 225 of file exec_ctx.h.
Definition at line 233 of file exec_ctx.h.
|
private |
Definition at line 230 of file exec_ctx.h.
Definition at line 229 of file exec_ctx.h.
|
private |
Definition at line 227 of file exec_ctx.h.