Go to the documentation of this file.
19 #ifndef GRPCPP_SUPPORT_CALLBACK_COMMON_H
20 #define GRPCPP_SUPPORT_CALLBACK_COMMON_H
39 template <
class Func,
class... Args>
41 #if GRPC_ALLOW_EXCEPTIONS
43 func(std::forward<Args>(args)...);
47 #else // GRPC_ALLOW_EXCEPTIONS
48 func(std::forward<Args>(args)...);
49 #endif // GRPC_ALLOW_EXCEPTIONS
52 template <
class Reactor,
class Func,
class... Args>
54 #if GRPC_ALLOW_EXCEPTIONS
56 return func(std::forward<Args>(args)...);
61 #else // GRPC_ALLOW_EXCEPTIONS
62 return func(std::forward<Args>(args)...);
63 #endif // GRPC_ALLOW_EXCEPTIONS
73 static void operator delete(
void* , std::size_t size) {
82 static void operator delete(
void*,
void*) {
GPR_ASSERT(
false); }
86 : call_(call), func_(
std::move(f)), ops_(ops) {
101 status_ = std::move(s);
107 std::function<void(
Status)> func_;
115 void* ignored = ops_;
124 auto func = std::move(func_);
125 auto status = std::move(status_);
139 static void operator delete(
void* , std::size_t size) {
148 static void operator delete(
void*,
void*) {
GPR_ASSERT(
false); }
168 func_ = std::move(f);
175 if (call_ !=
nullptr) {
192 operator bool()
const {
return call_ !=
nullptr; }
196 std::function<void(
bool)> func_;
203 void* ignored = ops_;
221 #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:136
~CallbackWithSuccessTag()
Definition: callback_common.h:155
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
#define GPR_DEBUG_ASSERT(x)
Definition: log.h:103
Status * status_ptr()
Definition: callback_common.h:95
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:95
Definition: callback_common.h:70
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:84
Did it work? If it didn't, why?
Definition: status.h:35
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:450
GRPCAPI void grpc_call_unref(grpc_call *call)
Unref a call.
void force_run(bool ok)
Definition: callback_common.h:188
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:70
void force_run(Status s)
Definition: callback_common.h:100
void Clear()
Definition: callback_common.h:174
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:163
void CatchingCallback(Func &&func, Args &&... args)
An exception-safe way of invoking a user-specified callback function.
Definition: callback_common.h:40
CallbackWithSuccessTag()
Definition: callback_common.h:150
Definition: async_unary_call.h:405
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:445
Reactor * CatchingReactorGetter(Func &&func, Args &&... args)
Definition: callback_common.h:53
::absl::Status Status
Definition: config_protobuf.h:97
CompletionQueueTag * ops()
Definition: callback_common.h:183
~CallbackWithStatusTag()
Definition: callback_common.h:94
int inlineable
The inlineable member specifies whether this functor can be run inline.
Definition: grpc_types.h:454