Go to the documentation of this file.
32 #ifndef GRPCPP_COMPLETION_QUEUE_H
33 #define GRPCPP_COMPLETION_QUEUE_H
37 #include "absl/log/absl_check.h"
58 template <
class W,
class R>
59 class ClientReaderWriter;
65 template <
class W,
class R>
68 template <
class ResponseType>
72 template <
class ServiceType,
class RequestType,
class ResponseType,
73 class BaseRequestType,
class BaseResponseType>
75 template <
class ServiceType,
class RequestType,
class ResponseType>
77 template <
class ServiceType,
class RequestType,
class ResponseType>
79 template <
class Streamer,
bool WriteNeeded>
81 template <grpc::StatusCode code>
95 template <
class InputMessage,
class OutputMessage>
97 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
178 bool Next(
void** tag,
bool* ok) {
199 template <
typename T>
202 return AsyncNextInternal(tag, ok, deadline_tp.
raw_time());
219 template <
typename T,
typename F>
221 CompletionQueueTLSCache cache = CompletionQueueTLSCache(
this);
223 if (cache.Flush(tag, ok)) {
255 InitialAvalanching();
270 template <
class W,
class R>
276 template <
class W,
class R>
278 template <
class ResponseType>
282 template <
class ServiceType,
class RequestType,
class ResponseType>
284 template <
class ServiceType,
class RequestType,
class ResponseType>
286 template <
class Streamer,
bool WriteNeeded>
288 template <grpc::StatusCode code>
292 template <
class InputMessage,
class OutputMessage>
299 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
306 class CompletionQueueTLSCache {
309 ~CompletionQueueTLSCache();
310 bool Flush(
void** tag,
bool* ok);
325 bool ok = ev.success != 0;
328 ABSL_CHECK(ignored == tag);
346 bool ok = ev.success != 0;
364 bool ok = ev.success != 0;
375 void InitialAvalanching() {
378 void RegisterAvalanching() {
381 void CompleteAvalanching() {
392 server_list_.push_back(server);
399 server_list_.remove(server);
402 bool ServerListEmpty()
const {
405 return server_list_.empty();
421 std::list<const grpc::Server*>
448 polling_type_(polling_type) {}
457 #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:83
@ GRPC_CQ_NEXT
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:431
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:98
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:411
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: completion_queue.h:82
Definition: rpc_service_method.h:43
A wrapper class of an application provided rpc method handler.
Definition: completion_queue.h:74
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:63
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:429
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:200
Definition: client_context.h:103
@ GRPC_QUEUE_SHUTDOWN
Shutting down.
Definition: grpc_types.h:227
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:220
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:66
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue.h:251
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:414
@ GRPC_CQ_NON_LISTENING
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:419
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: client_context.h:81
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:61
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:123
gpr_timespec raw_time()=delete
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
@ TIMEOUT
deadline was reached.
Definition: completion_queue.h:127
grpc_completion_queue * cq()
Returns a raw pointer to the underlying grpc_completion_queue instance.
Definition: completion_queue.h:247
Definition: grpc_types.h:462
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:78
bool IsFrequentlyPolled()
Definition: completion_queue.h:429
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:76
@ GOT_EVENT
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue.h:125
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:80
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:460
CompletionQueue()
Default constructor.
Definition: completion_queue.h:109
~CompletionQueue() override
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue.h:120
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:85
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:427
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:444
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:105
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:433
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:88
Definition: server_interface.h:61
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:60
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: completion_queue.h:124
@ GRPC_QUEUE_TIMEOUT
No event before timeout.
Definition: grpc_types.h:229
@ 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:178
#define gpr_atm_no_barrier_fetch_add(p, delta)
Definition: atm_gcc_atomic.h:45