19 #ifndef GRPC_CORE_LIB_IOMGR_EXEC_CTX_H 20 #define GRPC_CORE_LIB_IOMGR_EXEC_CTX_H 37 #define GRPC_MILLIS_INF_FUTURE INT64_MAX 38 #define GRPC_MILLIS_INF_PAST INT64_MIN 46 #define GRPC_EXEC_CTX_FLAG_IS_FINISHED 1 49 #define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2 52 #define GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD 4 56 #define GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD 1 151 uintptr_t
flags() {
return flags_; }
195 now_is_valid_ =
true;
203 now_is_valid_ =
true;
220 gpr_tls_set(&exec_ctx_, reinterpret_cast<intptr_t>(exec_ctx));
233 static void operator delete(
void* ) { abort(); }
239 CombinerData combiner_data_ = {
nullptr,
nullptr};
244 bool now_is_valid_ =
false;
247 GPR_TLS_CLASS_DECL(exec_ctx_);
307 if (reinterpret_cast<ApplicationCallbackExecCtx*>(
309 while (head_ !=
nullptr) {
312 if (f->internal_next ==
nullptr) {
315 (*f->functor_run)(f, f->internal_success);
317 gpr_tls_set(&callback_exec_ctx_, reinterpret_cast<intptr_t>(
nullptr));
328 if (reinterpret_cast<ApplicationCallbackExecCtx*>(
333 gpr_tls_set(&callback_exec_ctx_, reinterpret_cast<intptr_t>(exec_ctx));
345 if (ctx->head_ ==
nullptr) {
346 ctx->head_ = functor;
348 if (ctx->tail_ !=
nullptr) {
351 ctx->tail_ = functor;
361 uintptr_t flags_{0u};
364 GPR_TLS_CLASS_DECL(callback_exec_ctx_);
int64_t grpc_millis
Definition: exec_ctx.h:35
static void Set(ApplicationCallbackExecCtx *exec_ctx, uintptr_t flags)
Definition: exec_ctx.h:327
ExecCtx()
Default Constructor.
Definition: exec_ctx.h:108
#define GRPC_CLOSURE_LIST_INIT
Definition: closure.h:168
Combiner * last_combiner
Definition: exec_ctx.h:141
ExecCtx(uintptr_t fl)
Parameterised Constructor.
Definition: exec_ctx.h:114
static void Set(ExecCtx *exec_ctx)
Definition: exec_ctx.h:219
bool HasWork()
Checks if there is work to be done.
Definition: exec_ctx.h:154
virtual ~ExecCtx()
Destructor.
Definition: exec_ctx.h:122
Definition: debug_location.h:31
static void IncExecCtxCount()
Definition: fork.h:50
Definition: error_internal.h:39
ApplicationCallbackExecCtx()
Default Constructor.
Definition: exec_ctx.h:301
#define gpr_tls_destroy(tls)
Definition: tls_gcc.h:46
bool Flush()
Flush any work that has been enqueued onto this grpc_exec_ctx.
struct grpc_combiner grpc_combiner
A combiner represents a list of work to be executed later.
Definition: exec_ctx.h:42
grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec)
CombinerData * combiner_data()
Only to be used by grpc-combiner code.
Definition: exec_ctx.h:145
Execution context.
Definition: exec_ctx.h:104
#define GRPC_MILLIS_INF_FUTURE
Definition: exec_ctx.h:37
uintptr_t flags()
Return flags.
Definition: exec_ctx.h:151
Internal thread interface.
Definition: backoff.h:26
#define gpr_tls_init(tls)
Definition: tls_gcc.h:43
grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles)
static void Enqueue(grpc_experimental_completion_queue_functor *functor, int is_success)
Definition: exec_ctx.h:337
Definition: combiner.h:33
void InvalidateNow()
Invalidates the stored time value.
Definition: exec_ctx.h:190
ExecCtx & operator=(const ExecCtx &)=delete
#define GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD
Definition: exec_ctx.h:52
int internal_success
The following fields are not API.
Definition: grpc_types.h:734
grpc_closure_list * closure_list()
Return pointer to grpc_closure_list.
Definition: exec_ctx.h:148
static void GlobalShutdown(void)
Global shutdown for ApplicationCallbackExecCtx.
Definition: exec_ctx.h:358
static ExecCtx * Get()
Gets pointer to current exec_ctx.
Definition: exec_ctx.h:215
~ApplicationCallbackExecCtx()
Definition: exec_ctx.h:306
#define GRPC_EXEC_CTX_FLAG_IS_FINISHED
Definition: exec_ctx.h:46
static void Run(const DebugLocation &location, grpc_closure *closure, grpc_error *error)
grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles)
static void GlobalShutdown(void)
Global shutdown for ExecCtx.
Definition: exec_ctx.h:212
grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec)
ApplicationCallbackExecCtx(uintptr_t fl)
Parameterised Constructor.
Definition: exec_ctx.h:304
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
static void TestOnlyGlobalInit(gpr_timespec new_val)
intptr_t gpr_tls_set(struct gpr_pthread_thread_local *tls, intptr_t value)
static void DecExecCtxCount()
Definition: fork.h:57
void SetNowIomgrShutdown()
To be used only by shutdown code in iomgr.
Definition: exec_ctx.h:193
virtual bool CheckReadyToFinish()
Check if ready to finish.
Definition: exec_ctx.h:230
GPRAPI unsigned gpr_cpu_current_cpu(void)
Return the CPU on which the current thread is executing; N.B.
unsigned starting_cpu() const
Definition: exec_ctx.h:135
struct grpc_experimental_completion_queue_functor * internal_next
Definition: grpc_types.h:735
Analogous to struct timespec.
Definition: gpr_types.h:47
#define GPR_DEBUG_ASSERT(x)
Definition: log.h:103
gpr_clock_type
The clocks we support.
Definition: gpr_types.h:31
Definition: exec_ctx.h:137
bool IsReadyToFinish()
Returns true if we'd like to leave this execution context as soon as possible: useful for deciding wh...
Definition: exec_ctx.h:169
bool grpc_closure_list_empty(grpc_closure_list closure_list)
return whether list is empty.
Definition: closure.h:223
static void GlobalInit(void)
Global initialization for ApplicationCallbackExecCtx.
Definition: exec_ctx.h:355
static void RunList(const DebugLocation &location, grpc_closure_list *list)
Combiner * active_combiner
Definition: exec_ctx.h:139
static void GlobalInit(void)
Global initialization for ExecCtx.
#define gpr_tls_get(tls)
Definition: tls_gcc.h:50
EXPERIMENTAL: Specifies an interface class to be used as a tag for callback-based completion queues...
Definition: grpc_types.h:722
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock)
grpc_millis Now()
Returns the stored current time relative to start if valid, otherwise refreshes the stored time...
#define GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD
Definition: exec_ctx.h:56
Application-callback execution context.
Definition: exec_ctx.h:298
void TestOnlySetNow(grpc_millis new_val)
To be used only for testing.
Definition: exec_ctx.h:201