combiner.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_IOMGR_COMBINER_H
20 #define GRPC_CORE_LIB_IOMGR_COMBINER_H
21 
23 
24 #include <stddef.h>
25 
26 #include <grpc/support/atm.h>
27 
30 
31 namespace grpc_core {
32 // TODO(yashkt) : Remove this class and replace it with a class that does not
33 // use ExecCtx
34 class Combiner {
35  public:
37  // TODO(yashkt) : Remove this method
41  // either:
42  // a pointer to the initiating exec ctx if that is the only exec_ctx that has
43  // ever queued to this combiner, or NULL. If this is non-null, it's not
44  // dereferencable (since the initiating exec_ctx may have gone out of scope)
46  // state is:
47  // lower bit - zero if orphaned (STATE_UNORPHANED)
48  // other bits - number of items queued on the lock (STATE_ELEM_COUNT_LOW_BIT)
54 };
55 } // namespace grpc_core
56 
57 // Provides serialized access to some resource.
58 // Each action queued on a combiner is executed serially in a borrowed thread.
59 // The actual thread executing actions may change over time (but there will only
60 // ever be one at a time).
61 
62 // Initialize the lock, with an optional workqueue to shift load to when
63 // necessary
65 
66 #ifndef NDEBUG
67 #define GRPC_COMBINER_DEBUG_ARGS \
68  , const char *file, int line, const char *reason
69 #define GRPC_COMBINER_REF(combiner, reason) \
70  grpc_combiner_ref((combiner), __FILE__, __LINE__, (reason))
71 #define GRPC_COMBINER_UNREF(combiner, reason) \
72  grpc_combiner_unref((combiner), __FILE__, __LINE__, (reason))
73 #else
74 #define GRPC_COMBINER_DEBUG_ARGS
75 #define GRPC_COMBINER_REF(combiner, reason) grpc_combiner_ref((combiner))
76 #define GRPC_COMBINER_UNREF(combiner, reason) grpc_combiner_unref((combiner))
77 #endif
78 
79 // Ref/unref the lock, for when we're sharing the lock ownership
80 // Prefer to use the macros above
84 
86 
88 
89 #endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */
grpc_combiner_ref
grpc_core::Combiner * grpc_combiner_ref(grpc_core::Combiner *lock GRPC_COMBINER_DEBUG_ARGS)
Definition: combiner.cc:98
trace.h
grpc_core::Combiner::refs
gpr_refcount refs
Definition: combiner.h:53
grpc_core
Definition: call_metric_recorder.h:31
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_core::MultiProducerSingleConsumerQueue
Definition: mpscq.h:35
grpc_core::Combiner::next_combiner_on_this_exec_ctx
Combiner * next_combiner_on_this_exec_ctx
Definition: combiner.h:39
gpr_refcount
Definition: impl/codegen/sync_generic.h:39
grpc_core::Combiner::queue
MultiProducerSingleConsumerQueue queue
Definition: combiner.h:40
grpc_core::Combiner::Run
void Run(grpc_closure *closure, grpc_error_handle error)
Definition: combiner.cc:343
grpc_combiner_trace
grpc_core::DebugOnlyTraceFlag grpc_combiner_trace
grpc_combiner_create
grpc_core::Combiner * grpc_combiner_create(void)
Definition: combiner.cc:54
grpc_core::Combiner::initiating_exec_ctx_or_null
gpr_atm initiating_exec_ctx_or_null
Definition: combiner.h:45
grpc_core::Combiner::state
gpr_atm state
Definition: combiner.h:49
grpc_core::TraceFlag
Definition: debug/trace.h:63
grpc_closure_list
Definition: closure.h:41
gpr_atm
intptr_t gpr_atm
Definition: impl/codegen/atm_gcc_atomic.h:32
grpc_combiner_unref
void grpc_combiner_unref(grpc_core::Combiner *lock GRPC_COMBINER_DEBUG_ARGS)
Definition: combiner.cc:91
grpc_core::Combiner::time_to_execute_final_list
bool time_to_execute_final_list
Definition: combiner.h:50
grpc_core::Combiner::final_list
grpc_closure_list final_list
Definition: combiner.h:51
grpc_core::Combiner::FinallyRun
void FinallyRun(grpc_closure *closure, grpc_error_handle error)
Definition: combiner.cc:347
exec_ctx.h
closure
Definition: proxy.cc:59
grpc_core::Combiner
Definition: combiner.h:34
grpc_core::Combiner::offload
grpc_closure offload
Definition: combiner.h:52
GRPC_COMBINER_DEBUG_ARGS
#define GRPC_COMBINER_DEBUG_ARGS
Definition: combiner.h:67
atm.h
grpc_error
Definition: error_internal.h:42
grpc_closure
Definition: closure.h:56
grpc_combiner_continue_exec_ctx
bool grpc_combiner_continue_exec_ctx()
Definition: combiner.cc:181
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:50