Go to the documentation of this file.
32 #ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H
33 #define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H
53 template <
class W,
class R>
54 class ClientReaderWriter;
60 template <
class W,
class R>
63 template <
class ResponseType>
65 const ::grpc::internal::MethodHandler::HandlerParameter&, ResponseType*,
67 template <
class ServiceType,
class RequestType,
class ResponseType,
68 class BaseRequestType,
class BaseResponseType>
70 template <
class ServiceType,
class RequestType,
class ResponseType>
72 template <
class ServiceType,
class RequestType,
class ResponseType>
74 template <
class Streamer,
bool WriteNeeded>
76 template <::grpc::StatusCode code>
90 template <
class InputMessage,
class OutputMessage>
92 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
177 bool Next(
void** tag,
bool* ok) {
178 return (AsyncNextInternal(tag, ok,
194 template <
typename T>
197 return AsyncNextInternal(tag, ok, deadline_tp.
raw_time());
214 template <
typename T,
typename F>
216 CompletionQueueTLSCache cache = CompletionQueueTLSCache(
this);
218 if (cache.Flush(tag, ok)) {
250 &attributes,
nullptr);
251 InitialAvalanching();
257 friend class ::grpc::ServerBuilder;
258 friend class ::grpc::Server;
263 friend class ::grpc::ClientReader;
265 friend class ::grpc::ClientWriter;
266 template <
class W,
class R>
267 friend class ::grpc::ClientReaderWriter;
269 friend class ::grpc::ServerReader;
271 friend class ::grpc::ServerWriter;
272 template <
class W,
class R>
273 friend class ::grpc::internal::ServerReaderWriterBody;
274 template <
class ResponseType>
276 const ::grpc::internal::MethodHandler::HandlerParameter&, ResponseType*,
278 template <
class ServiceType,
class RequestType,
class ResponseType>
279 friend class ::grpc::internal::ClientStreamingHandler;
280 template <
class ServiceType,
class RequestType,
class ResponseType>
281 friend class ::grpc::internal::ServerStreamingHandler;
282 template <
class Streamer,
bool WriteNeeded>
283 friend class ::grpc::internal::TemplatedBidiStreamingHandler;
284 template <::grpc::StatusCode code>
285 friend class ::grpc::internal::ErrorMethodHandler;
287 friend class ::grpc::ServerInterface;
288 template <
class InputMessage,
class OutputMessage>
289 friend class ::grpc::internal::BlockingUnaryCallImpl;
292 friend class ::grpc::Channel;
295 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
296 friend class ::grpc::internal::CallOpSet;
302 class CompletionQueueTLSCache {
305 ~CompletionQueueTLSCache();
306 bool Flush(
void** tag,
bool* ok);
322 cq_, tag, deadline,
nullptr);
344 cq_, tag, deadline,
nullptr);
360 cq_, tag, deadline,
nullptr);
376 void InitialAvalanching() {
379 void RegisterAvalanching() {
383 void CompleteAvalanching() {
385 static_cast<gpr_atm>(-1)) == 1) {
390 void RegisterServer(const ::grpc::Server* server) {
394 server_list_.push_back(server);
397 void UnregisterServer(const ::grpc::Server* server) {
401 server_list_.remove(server);
404 bool ServerListEmpty()
const {
407 return server_list_.empty();
420 std::list<const ::grpc::Server*>
447 polling_type_(polling_type) {}
450 friend class ::grpc::ServerBuilder;
451 friend class ::grpc::Server;
456 #endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:38
void Shutdown()
Request the shutdown of the queue.
virtual gpr_timespec gpr_time_0(gpr_clock_type type)=0
virtual grpc_completion_queue * grpc_completion_queue_create(const grpc_completion_queue_factory *factory, const grpc_completion_queue_attributes *attributes, void *reserved)=0
@ GRPC_CQ_NEXT
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:729
Represents a gRPC server.
Definition: server.h:59
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: call_op_set.h:852
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:709
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: byte_buffer.h:49
A wrapper class of an application provided rpc method handler.
Definition: completion_queue.h:69
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:58
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:727
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:195
Definition: channel_interface.h:67
@ GRPC_QUEUE_SHUTDOWN
Shutting down.
Definition: grpc_types.h:523
Base class of ServerContext. Experimental until callback API is final.
Definition: server_context.h:131
::grpc::ServerContextBase ServerContextBase
Definition: server_context.h:108
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:215
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
The zero time interval.
Definition: completion_queue.h:61
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue.h:246
virtual gpr_timespec gpr_inf_future(gpr_clock_type type)=0
Did it work? If it didn't, why?
Definition: status.h:31
@ 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:712
@ GRPC_CQ_NON_LISTENING
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:717
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:56
EXPERIMENTAL: Specifies an interface class to be used as a tag for callback-based completion queues.
Definition: grpc_types.h:743
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.
NextStatus
Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
Definition: completion_queue.h:122
gpr_timespec raw_time()=delete
#define gpr_atm_rel_store(p, value)
Definition: atm_gcc_atomic.h:52
#define gpr_atm_no_barrier_fetch_add(p, delta)
Definition: atm_gcc_atomic.h:57
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:242
Definition: grpc_types.h:763
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:38
intptr_t gpr_atm
Definition: atm_gcc_atomic.h:30
A wrapper class of an application provided server streaming handler.
Definition: byte_buffer.h:47
bool IsFrequentlyPolled()
Definition: completion_queue.h:428
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:71
@ GOT_EVENT
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue.h:124
A wrapper class of an application provided bidi-streaming handler.
Definition: completion_queue.h:75
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:761
CompletionQueue()
Default constructor.
Definition: completion_queue.h:106
~CompletionQueue() override
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue.h:117
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:56
virtual bool FinalizeResult(void **tag, bool *status)=0
FinalizeResult must be called before informing user code that the operation bound to the underlying c...
virtual void grpc_completion_queue_destroy(grpc_completion_queue *cq)=0
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: channel.h:54
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue.h:96
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
Descriptor of an RPC method.
Definition: rpc_method.h:29
ServerCompletionQueue()
Default constructor.
Definition: completion_queue.h:432
virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)=0
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:90
Definition: server_interface.h:65
void UnaryRunHandlerHelper(const ::grpc::internal::MethodHandler::HandlerParameter &, ResponseType *, ::grpc::Status &)
Analogous to struct timespec.
Definition: gpr_types.h:47
virtual void grpc_completion_queue_shutdown(grpc_completion_queue *cq)=0
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: completion_queue.h:123
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: gpr_types.h:36
int success
If the grpc_completion_type is GRPC_OP_COMPLETE, this field indicates whether the operation was succe...
Definition: grpc_types.h:541
@ GRPC_QUEUE_TIMEOUT
No event before timeout.
Definition: grpc_types.h:525
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