Go to the documentation of this file.
32 #ifndef GRPCPP_COMPLETION_QUEUE_H
33 #define GRPCPP_COMPLETION_QUEUE_H
56 template <
class W,
class R>
57 class ClientReaderWriter;
63 template <
class W,
class R>
66 template <
class ResponseType>
70 template <
class ServiceType,
class RequestType,
class ResponseType,
71 class BaseRequestType,
class BaseResponseType>
73 template <
class ServiceType,
class RequestType,
class ResponseType>
75 template <
class ServiceType,
class RequestType,
class ResponseType>
77 template <
class Streamer,
bool WriteNeeded>
79 template <grpc::StatusCode code>
93 template <
class InputMessage,
class OutputMessage>
95 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
176 bool Next(
void** tag,
bool* ok) {
197 template <
typename T>
200 return AsyncNextInternal(tag, ok, deadline_tp.
raw_time());
217 template <
typename T,
typename F>
219 CompletionQueueTLSCache cache = CompletionQueueTLSCache(
this);
221 if (cache.Flush(tag, ok)) {
253 InitialAvalanching();
268 template <
class W,
class R>
274 template <
class W,
class R>
276 template <
class ResponseType>
280 template <
class ServiceType,
class RequestType,
class ResponseType>
282 template <
class ServiceType,
class RequestType,
class ResponseType>
284 template <
class Streamer,
bool WriteNeeded>
286 template <grpc::StatusCode code>
290 template <
class InputMessage,
class OutputMessage>
297 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
304 class CompletionQueueTLSCache {
307 ~CompletionQueueTLSCache();
308 bool Flush(
void** tag,
bool* ok);
323 bool ok = ev.success != 0;
344 bool ok = ev.success != 0;
362 bool ok = ev.success != 0;
373 void InitialAvalanching() {
376 void RegisterAvalanching() {
379 void CompleteAvalanching() {
390 server_list_.push_back(server);
397 server_list_.remove(server);
400 bool ServerListEmpty()
const {
403 return server_list_.empty();
419 std::list<const grpc::Server*>
446 polling_type_(polling_type) {}
455 #endif // GRPCPP_COMPLETION_QUEUE_H
void Shutdown()
Request the shutdown of the queue.
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: client_context.h:81
@ GRPC_CQ_NEXT
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:770
Represents a gRPC server.
Definition: server.h:58
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:32
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:96
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:750
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: completion_queue.h:80
Definition: rpc_service_method.h:41
A wrapper class of an application provided rpc method handler.
Definition: completion_queue.h:72
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:61
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:768
NextStatus AsyncNext(void **tag, bool *ok, const T &deadline)
Read from the queue, blocking up to deadline (or the queue's shutdown).
Definition: completion_queue.h:198
Definition: client_context.h:101
@ GRPC_QUEUE_SHUTDOWN
Shutting down.
Definition: grpc_types.h:566
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:95
Base class of ServerContext.
Definition: server_context.h:124
intptr_t gpr_atm
Definition: atm_gcc_atomic.h:32
NextStatus DoThenAsyncNext(F &&f, void **tag, bool *ok, const T &deadline)
EXPERIMENTAL First executes F, then reads from the queue, blocking up to deadline (or the queue's shu...
Definition: completion_queue.h:218
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
The far future.
GRPCAPI grpc_completion_queue * grpc_completion_queue_create(const grpc_completion_queue_factory *factory, const grpc_completion_queue_attributes *attributes, void *reserved)
Create a completion queue.
Definition: completion_queue.h:64
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue.h:249
Did it work? If it didn't, why?
Definition: status.h:35
@ GRPC_CQ_DEFAULT_POLLING
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:753
@ GRPC_CQ_NON_LISTENING
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:758
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: client_context.h:79
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:59
const GRPCAPI grpc_completion_queue_factory * grpc_completion_queue_factory_lookup(const grpc_completion_queue_attributes *attributes)
Returns the completion queue factory based on the attributes.
GPRAPI gpr_timespec gpr_time_0(gpr_clock_type type)
Time constants.
NextStatus
Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
Definition: completion_queue.h:121
gpr_timespec raw_time()=delete
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
@ TIMEOUT
deadline was reached.
Definition: completion_queue.h:125
grpc_completion_queue * cq()
Returns a raw pointer to the underlying grpc_completion_queue instance.
Definition: completion_queue.h:245
Definition: grpc_types.h:801
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:32
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)
Blocks until an event with tag 'tag' is available, the completion queue is being shutdown or deadline...
A wrapper class of an application provided server streaming handler.
Definition: completion_queue.h:76
bool IsFrequentlyPolled()
Definition: completion_queue.h:427
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:74
@ GOT_EVENT
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue.h:123
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq)
Destroy a completion queue.
A wrapper class of an application provided bidi-streaming handler.
Definition: completion_queue.h:78
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:799
CompletionQueue()
Default constructor.
Definition: completion_queue.h:107
~CompletionQueue() override
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue.h:118
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:83
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:425
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:58
virtual bool FinalizeResult(void **tag, bool *status)=0
FinalizeResult must be called before informing user code that the operation bound to the underlying c...
GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq)
Begin destruction of a completion queue.
Specifies an interface class to be used as a tag for callback-based completion queues.
Definition: grpc_types.h:783
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:103
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: channel.h:54
#define gpr_atm_rel_store(p, value)
Definition: atm_gcc_atomic.h:40
Descriptor of an RPC method.
Definition: rpc_method.h:29
ServerCompletionQueue()
Default constructor.
Definition: completion_queue.h:431
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:85
Definition: server_interface.h:60
Analogous to struct timespec.
Definition: time.h:48
void UnaryRunHandlerHelper(const grpc::internal::MethodHandler::HandlerParameter &, ResponseType *, grpc::Status &)
A helper function with reduced templating to do the common work needed to actually send the server re...
Definition: method_handler.h:58
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: completion_queue.h:122
@ GRPC_QUEUE_TIMEOUT
No event before timeout.
Definition: grpc_types.h:568
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: time.h:37
If you are trying to use CompletionQueue::AsyncNext with a time class that isn't either gpr_timespec ...
Definition: time.h:40
bool Next(void **tag, bool *ok)
Read from the queue, blocking until an event is available or the queue is shutting down.
Definition: completion_queue.h:176
#define gpr_atm_no_barrier_fetch_add(p, delta)
Definition: atm_gcc_atomic.h:45