Go to the documentation of this file.
32 #ifndef GRPCPP_COMPLETION_QUEUE_H
33 #define GRPCPP_COMPLETION_QUEUE_H
48 #include "absl/log/absl_check.h"
57 template <
class W,
class R>
58 class ClientReaderWriter;
64 template <
class W,
class R>
67 template <
class ResponseType>
71 template <
class ServiceType,
class RequestType,
class ResponseType,
72 class BaseRequestType,
class BaseResponseType>
74 template <
class ServiceType,
class RequestType,
class ResponseType>
76 template <
class ServiceType,
class RequestType,
class ResponseType>
78 template <
class Streamer,
bool WriteNeeded>
80 template <grpc::StatusCode code>
94 template <
class InputMessage,
class OutputMessage>
96 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
177 bool Next(
void** tag,
bool* ok) {
198 template <
typename T>
201 return AsyncNextInternal(tag, ok, deadline_tp.
raw_time());
218 template <
typename T,
typename F>
220 CompletionQueueTLSCache cache = CompletionQueueTLSCache(
this);
222 if (cache.Flush(tag, ok)) {
254 InitialAvalanching();
269 template <
class W,
class R>
275 template <
class W,
class R>
277 template <
class ResponseType>
281 template <
class ServiceType,
class RequestType,
class ResponseType>
283 template <
class ServiceType,
class RequestType,
class ResponseType>
285 template <
class Streamer,
bool WriteNeeded>
287 template <grpc::StatusCode code>
291 template <
class InputMessage,
class OutputMessage>
298 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
305 class CompletionQueueTLSCache {
308 ~CompletionQueueTLSCache();
309 bool Flush(
void** tag,
bool* ok);
324 bool ok = ev.success != 0;
327 ABSL_CHECK(ignored == tag);
345 bool ok = ev.success != 0;
363 bool ok = ev.success != 0;
374 void InitialAvalanching() {
377 void RegisterAvalanching() {
380 void CompleteAvalanching() {
391 server_list_.push_back(server);
398 server_list_.remove(server);
401 bool ServerListEmpty()
const {
404 return server_list_.empty();
420 std::list<const grpc::Server*>
447 polling_type_(polling_type) {}
456 #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:82
@ GRPC_CQ_NEXT
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:430
Represents a gRPC server.
Definition: server.h:57
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:97
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:410
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: completion_queue.h:81
Definition: rpc_service_method.h:43
A wrapper class of an application provided rpc method handler.
Definition: completion_queue.h:73
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:62
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:428
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:199
Definition: client_context.h:102
@ GRPC_QUEUE_SHUTDOWN
Shutting down.
Definition: grpc_types.h:226
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:219
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:65
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue.h:250
Did it work? If it didn't, why?
Definition: status.h:34
@ 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:413
@ GRPC_CQ_NON_LISTENING
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:418
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: client_context.h:80
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:60
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:122
gpr_timespec raw_time()=delete
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
@ TIMEOUT
deadline was reached.
Definition: completion_queue.h:126
grpc_completion_queue * cq()
Returns a raw pointer to the underlying grpc_completion_queue instance.
Definition: completion_queue.h:246
Definition: grpc_types.h:461
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:77
bool IsFrequentlyPolled()
Definition: completion_queue.h:428
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:75
@ GOT_EVENT
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue.h:124
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:79
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:459
CompletionQueue()
Default constructor.
Definition: completion_queue.h:108
~CompletionQueue() override
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue.h:119
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:84
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:426
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:57
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:443
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
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:432
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:88
Definition: server_interface.h:60
Analogous to struct timespec.
Definition: time.h:47
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:59
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: completion_queue.h:123
@ GRPC_QUEUE_TIMEOUT
No event before timeout.
Definition: grpc_types.h:228
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: time.h:36
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:177
#define gpr_atm_no_barrier_fetch_add(p, delta)
Definition: atm_gcc_atomic.h:45