|
GRPC Core
9.0.0
|
Execution context. More...
#include <exec_ctx.h>
Data Structures | |
| struct | CombinerData |
Public Member Functions | |
| ExecCtx () | |
| Default Constructor. More... | |
| ExecCtx (uintptr_t fl) | |
| Parameterised Constructor. More... | |
| virtual | ~ExecCtx () |
| Destructor. More... | |
| ExecCtx (const ExecCtx &)=delete | |
| Disallow copy and assignment operators. More... | |
| ExecCtx & | operator= (const ExecCtx &)=delete |
| unsigned | starting_cpu () const |
| CombinerData * | combiner_data () |
| Only to be used by grpc-combiner code. More... | |
| grpc_closure_list * | closure_list () |
| Return pointer to grpc_closure_list. More... | |
| uintptr_t | flags () |
| Return flags. More... | |
| bool | HasWork () |
| Checks if there is work to be done. More... | |
| bool | Flush () |
| Flush any work that has been enqueued onto this grpc_exec_ctx. More... | |
| bool | IsReadyToFinish () |
| 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. More... | |
| grpc_millis | Now () |
| Returns the stored current time relative to start if valid, otherwise refreshes the stored time, sets it valid and returns the new value. More... | |
| void | InvalidateNow () |
| Invalidates the stored time value. More... | |
| void | SetNowIomgrShutdown () |
| To be used only by shutdown code in iomgr. More... | |
| void | TestOnlySetNow (grpc_millis new_val) |
| To be used only for testing. More... | |
Static Public Member Functions | |
| static void | TestOnlyGlobalInit (gpr_timespec new_val) |
| static void | GlobalInit (void) |
| Global initialization for ExecCtx. More... | |
| static void | GlobalShutdown (void) |
| Global shutdown for ExecCtx. More... | |
| static ExecCtx * | Get () |
| Gets pointer to current exec_ctx. More... | |
| static void | Set (ExecCtx *exec_ctx) |
| static void | Run (const DebugLocation &location, grpc_closure *closure, grpc_error *error) |
| static void | RunList (const DebugLocation &location, grpc_closure_list *list) |
Protected Member Functions | |
| virtual bool | CheckReadyToFinish () |
| Check if ready to finish. More... | |
Static Protected Member Functions | |
| static void | operator delete (void *) |
| Disallow delete on ExecCtx. More... | |
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 :
grpc_core::ExecCtx exec_ctx;
Access the created ExecCtx instance using : grpc_core::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.
|
inline |
Default Constructor.
|
inline |
Parameterised Constructor.
|
inlinevirtual |
Destructor.
|
delete |
Disallow copy and assignment operators.
|
inlineprotectedvirtual |
Check if ready to finish.
Reimplemented in ExecCtxPluck, and ExecCtxNext.
|
inline |
Return pointer to grpc_closure_list.
|
inline |
Only to be used by grpc-combiner code.
|
inline |
Return flags.
| 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.
|
inlinestatic |
Gets pointer to current exec_ctx.
|
static |
Global initialization for ExecCtx.
Called by iomgr.
|
inlinestatic |
Global shutdown for ExecCtx.
Called by iomgr.
|
inline |
Checks if there is work to be done.
|
inline |
Invalidates the stored time value.
A new time value will be set on calling Now().
|
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.
| grpc_millis 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.
|
inlinestaticprotected |
Disallow delete on ExecCtx.
|
static |
|
static |
|
inlinestatic |
|
inline |
To be used only by shutdown code in iomgr.
|
inline |
|
static |
|
inline |
To be used only for testing.
Sets the now value.