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>
61 class ServerReaderWriterBody;
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>
88 class CompletionQueueTag;
90 template <
class InputMessage,
class OutputMessage>
91 class BlockingUnaryCallImpl;
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();
423 std::list<const ::grpc::Server*>
450 polling_type_(polling_type) {}
453 friend class ::grpc::ServerBuilder;
454 friend class ::grpc::Server;
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: channel.h:57
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
CompletionQueue(grpc_completion_queue *take)
Wrap take, taking ownership of the instance.
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
void Shutdown()
Request the shutdown of the queue.
NextStatus
Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
Definition: completion_queue.h:122
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: completion_queue.h:123
@ GOT_EVENT
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue.h:124
@ TIMEOUT
deadline was reached.
Definition: completion_queue.h:126
~CompletionQueue() override
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue.h:117
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
grpc_completion_queue * cq()
Returns a raw pointer to the underlying grpc_completion_queue instance.
Definition: completion_queue.h:242
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue.h:246
CompletionQueue()
Default constructor.
Definition: completion_queue.h:106
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
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:38
virtual void grpc_completion_queue_destroy(grpc_completion_queue *cq)=0
virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)=0
virtual void grpc_completion_queue_shutdown(grpc_completion_queue *cq)=0
virtual gpr_timespec gpr_inf_future(gpr_clock_type type)=0
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
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:38
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:85
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:429
ServerCompletionQueue()
Default constructor.
Definition: completion_queue.h:435
bool IsFrequentlyPolled()
Definition: completion_queue.h:431
Base class of ServerContext. Experimental until callback API is final.
Definition: server_context.h:126
Represents a gRPC server.
Definition: server.h:59
Definition: server_interface.h:59
Did it work? If it didn't, why?
Definition: status.h:31
If you are trying to use CompletionQueue::AsyncNext with a time class that isn't either gpr_timespec ...
Definition: time.h:40
gpr_timespec raw_time()=delete
A wrapper class of an application provided client streaming handler.
Definition: method_handler.h:141
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
virtual bool FinalizeResult(void **tag, bool *status)=0
FinalizeResult must be called before informing user code that the operation bound to the underlying c...
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: method_handler.h:358
A wrapper class of an application provided rpc method handler.
Definition: method_handler.h:98
A wrapper class of an application provided server streaming handler.
Definition: method_handler.h:189
A wrapper class of an application provided bidi-streaming handler.
Definition: method_handler.h:262
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: gpr_types.h:36
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
The zero time interval.
GRPCAPI const grpc_completion_queue_factory * grpc_completion_queue_factory_lookup(const grpc_completion_queue_attributes *attributes)
Returns the completion queue factory based on the attributes.
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:742
@ GRPC_CQ_NEXT
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:744
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:776
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:724
@ GRPC_CQ_NON_LISTENING
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:732
@ 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:727
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:56
@ GRPC_QUEUE_TIMEOUT
No event before timeout.
Definition: grpc_types.h:540
@ GRPC_QUEUE_SHUTDOWN
Shutting down.
Definition: grpc_types.h:538
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
intptr_t gpr_atm
Definition: atm_gcc_atomic.h:30
#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
::grpc::ServerContextBase ServerContextBase
Definition: server_context.h:108
void UnaryRunHandlerHelper(const ::grpc::internal::MethodHandler::HandlerParameter &, ResponseType *, ::grpc::Status &)
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue.h:96
Analogous to struct timespec.
Definition: gpr_types.h:47
Definition: grpc_types.h:778
Specifies an interface class to be used as a tag for callback-based completion queues.
Definition: grpc_types.h:757
int success
If the grpc_completion_type is GRPC_OP_COMPLETE, this field indicates whether the operation was succe...
Definition: grpc_types.h:556