Go to the documentation of this file.
19 #ifndef GRPCPP_SUPPORT_CALLBACK_COMMON_H
20 #define GRPCPP_SUPPORT_CALLBACK_COMMON_H
33 #include "absl/log/absl_check.h"
41 template <
class Func,
class... Args>
43 #if GRPC_ALLOW_EXCEPTIONS
45 func(std::forward<Args>(args)...);
49 #else // GRPC_ALLOW_EXCEPTIONS
50 func(std::forward<Args>(args)...);
51 #endif // GRPC_ALLOW_EXCEPTIONS
54 template <
class Reactor,
class Func,
class... Args>
56 #if GRPC_ALLOW_EXCEPTIONS
58 return func(std::forward<Args>(args)...);
63 #else // GRPC_ALLOW_EXCEPTIONS
64 return func(std::forward<Args>(args)...);
65 #endif // GRPC_ALLOW_EXCEPTIONS
75 static void operator delete(
void* , std::size_t size) {
84 static void operator delete(
void*,
void*) { ABSL_CHECK(
false); }
88 : call_(call), func_(
std::move(f)), ops_(ops) {
103 status_ = std::move(s);
109 std::function<void(
Status)> func_;
117 void* ignored = ops_;
123 ABSL_CHECK(ignored == ops_);
126 auto func = std::move(func_);
127 auto status = std::move(status_);
131 call_, [func = std::move(func), status = std::move(status)]() {
132 #if GRPC_ALLOW_EXCEPTIONS
138 #else // GRPC_ALLOW_EXCEPTIONS
140 #endif // GRPC_ALLOW_EXCEPTIONS
152 static void operator delete(
void* , std::size_t size) {
161 static void operator delete(
void*,
void*) { ABSL_CHECK(
false); }
178 ABSL_CHECK_EQ(call_,
nullptr);
181 func_ = std::move(f);
188 if (call_ !=
nullptr) {
205 operator bool()
const {
return call_ !=
nullptr; }
209 std::function<void(
bool)> func_;
216 void* ignored = ops_;
224 ABSL_DCHECK(ignored ==
ops);
229 #if GRPC_ALLOW_EXCEPTIONS
235 #else // GRPC_ALLOW_EXCEPTIONS
237 #endif // GRPC_ALLOW_EXCEPTIONS
246 #endif // GRPCPP_SUPPORT_CALLBACK_COMMON_H
CallbackWithSuccessTag can be reused multiple times, and will be used in this fashion for streaming o...
Definition: callback_common.h:149
~CallbackWithSuccessTag()
Definition: callback_common.h:168
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
Status * status_ptr()
Definition: callback_common.h:97
Definition: callback_common.h:72
GRPCAPI void grpc_call_ref(grpc_call *call)
Ref a call.
CallbackWithStatusTag(grpc_call *call, std::function< void(Status)> f, CompletionQueueTag *ops)
Definition: callback_common.h:86
Did it work? If it didn't, why?
Definition: status.h:34
CallbackWithSuccessTag & operator=(const CallbackWithSuccessTag &)=delete
void(* functor_run)(struct grpc_completion_queue_functor *, int)
The run member specifies a function that will be called when this tag is extracted from the completio...
Definition: grpc_types.h:448
GRPCAPI void grpc_call_unref(grpc_call *call)
Unref a call.
void force_run(bool ok)
Definition: callback_common.h:201
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:68
void force_run(Status s)
Definition: callback_common.h:102
void Clear()
Definition: callback_common.h:187
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
void Set(grpc_call *call, std::function< void(bool)> f, CompletionQueueTag *ops, bool can_inline)
Definition: callback_common.h:176
void CatchingCallback(Func &&func, Args &&... args)
An exception-safe way of invoking a user-specified callback function.
Definition: callback_common.h:42
CallbackWithSuccessTag()
Definition: callback_common.h:163
Definition: async_unary_call.h:406
virtual bool FinalizeResult(void **tag, bool *status)=0
FinalizeResult must be called before informing user code that the operation bound to the underlying c...
Specifies an interface class to be used as a tag for callback-based completion queues.
Definition: grpc_types.h:443
std::shared_ptr< GlobalCallbackHook > GetGlobalCallbackHook()
Reactor * CatchingReactorGetter(Func &&func, Args &&... args)
Definition: callback_common.h:55
::absl::Status Status
Definition: config_protobuf.h:107
CompletionQueueTag * ops()
Definition: callback_common.h:196
~CallbackWithStatusTag()
Definition: callback_common.h:96
int inlineable
The inlineable member specifies whether this functor can be run inline.
Definition: grpc_types.h:452