Go to the documentation of this file.
19 #ifndef GRPCPP_SUPPORT_CALLBACK_COMMON_H
20 #define GRPCPP_SUPPORT_CALLBACK_COMMON_H
24 #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_);
141 static void operator delete(
void* , std::size_t size) {
150 static void operator delete(
void*,
void*) { ABSL_CHECK(
false); }
167 ABSL_CHECK_EQ(call_,
nullptr);
170 func_ = std::move(f);
177 if (call_ !=
nullptr) {
194 operator bool()
const {
return call_ !=
nullptr; }
198 std::function<void(
bool)> func_;
205 void* ignored = ops_;
213 ABSL_DCHECK(ignored ==
ops);
225 #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:138
~CallbackWithSuccessTag()
Definition: callback_common.h:157
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:449
GRPCAPI void grpc_call_unref(grpc_call *call)
Unref a call.
void force_run(bool ok)
Definition: callback_common.h:190
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:69
void force_run(Status s)
Definition: callback_common.h:102
void Clear()
Definition: callback_common.h:176
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:165
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:152
Definition: async_unary_call.h:407
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:444
Reactor * CatchingReactorGetter(Func &&func, Args &&... args)
Definition: callback_common.h:55
::absl::Status Status
Definition: config_protobuf.h:106
CompletionQueueTag * ops()
Definition: callback_common.h:185
~CallbackWithStatusTag()
Definition: callback_common.h:96
int inlineable
The inlineable member specifies whether this functor can be run inline.
Definition: grpc_types.h:453