Go to the documentation of this file.
32 #ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H
33 #define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H
56 template <
class W,
class R>
64 template <
class W,
class R>
67 template <
class ServiceType,
class RequestType,
class ResponseType>
69 template <
class ServiceType,
class RequestType,
class ResponseType>
71 template <
class ServiceType,
class RequestType,
class ResponseType>
73 template <
class Streamer,
bool WriteNeeded>
75 template <::grpc::StatusCode code>
81 class ChannelInterface;
82 class ServerInterface;
85 class CompletionQueueTag;
87 template <
class InputMessage,
class OutputMessage>
88 class BlockingUnaryCallImpl;
89 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
178 bool Next(
void** tag,
bool* ok) {
179 return (AsyncNextInternal(tag, ok,
195 template <
typename T>
198 return AsyncNextInternal(tag, ok, deadline_tp.
raw_time());
215 template <
typename T,
typename F>
217 CompletionQueueTLSCache cache = CompletionQueueTLSCache(
this);
219 if (cache.Flush(tag, ok)) {
252 InitialAvalanching();
267 template <
class W,
class R>
273 template <
class W,
class R>
274 friend class ::grpc_impl::internal::ServerReaderWriterBody;
275 template <
class ServiceType,
class RequestType,
class ResponseType>
277 template <
class ServiceType,
class RequestType,
class ResponseType>
279 template <
class ServiceType,
class RequestType,
class ResponseType>
281 template <
class Streamer,
bool WriteNeeded>
283 template <::grpc::StatusCode code>
286 friend class ::grpc::ServerInterface;
287 template <
class InputMessage,
class OutputMessage>
288 friend class ::grpc::internal::BlockingUnaryCallImpl;
294 template <
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6>
295 friend class ::grpc::internal::CallOpSet;
301 class CompletionQueueTLSCache {
304 ~CompletionQueueTLSCache();
305 bool Flush(
void** tag,
bool* ok);
321 cq_, tag, deadline,
nullptr);
343 cq_, tag, deadline,
nullptr);
359 cq_, tag, deadline,
nullptr);
375 void InitialAvalanching() {
378 void RegisterAvalanching() {
380 static_cast<gpr_atm>(1));
382 void CompleteAvalanching() {
384 static_cast<gpr_atm>(-1)) == 1) {
389 void RegisterServer(
const Server* server) {
393 server_list_.push_back(server);
396 void UnregisterServer(
const Server* server) {
400 server_list_.remove(server);
403 bool ServerListEmpty()
const {
406 return server_list_.empty();
419 std::list<const Server*> server_list_ ;
445 polling_type_(polling_type) {}
454 #endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:38
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: byte_buffer.h:44
::grpc_impl::internal::RpcMethodHandler< ServiceType, RequestType, ResponseType > RpcMethodHandler
Definition: method_handler.h:36
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
Events are popped out by calling grpc_completion_queue_next() API ONLY.
Definition: grpc_types.h:725
A wrapper class of an application provided client streaming handler.
Definition: completion_queue_impl.h:70
::grpc_impl::internal::TemplatedBidiStreamingHandler< Streamer, WriteNeeded > TemplatedBidiStreamingHandler
Definition: method_handler.h:50
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc_cq_polling_type
Completion queues internally MAY maintain a set of file descriptors in a structure called 'pollset'.
Definition: grpc_types.h:705
grpc_cq_completion_type
Specifies the type of APIs to use to pop events from the completion queue.
Definition: grpc_types.h:723
::grpc_impl::ClientWriter< W > ClientWriter
Definition: sync_stream.h:62
Shutting down.
Definition: grpc_types.h:521
Base class of ServerContext. Experimental until callback API is final.
Definition: server_context_impl.h:123
::grpc_impl::Server Server
Definition: server.h:26
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
The zero time interval.
~CompletionQueue()
Destructor. Destroys the owned wrapped completion queue / instance.
Definition: completion_queue_impl.h:118
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue_impl.h:424
::grpc_impl::ServerWriter< W > ServerWriter
Definition: sync_stream.h:81
virtual gpr_timespec gpr_inf_future(gpr_clock_type type)=0
::grpc_impl::internal::ServerStreamingHandler< ServiceType, RequestType, ResponseType > ServerStreamingHandler
Definition: method_handler.h:46
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:708
Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will not contain any 'listening ...
Definition: grpc_types.h:713
CompletionQueue()
Default constructor.
Definition: completion_queue_impl.h:107
EXPERIMENTAL: Specifies an interface class to be used as a tag for callback-based completion queues.
Definition: grpc_types.h:739
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.
bool IsFrequentlyPolled()
Definition: completion_queue_impl.h:426
gpr_timespec raw_time()=delete
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue_impl.h:61
::grpc_impl::ServerReader< R > ServerReader
Definition: sync_stream.h:75
A wrapper class of an application provided rpc method handler.
Definition: byte_buffer.h:40
#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
Definition: grpc_types.h:759
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_impl.h:178
::grpc_impl::ServerContextBase ServerContextBase
Definition: server_context.h:36
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
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_impl.h:196
A wrapper class of an application provided bidi-streaming handler.
Definition: completion_queue_impl.h:74
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue_impl.h:103
Definition: completion_queue_impl.h:65
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:757
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:56
::grpc_impl::ClientReader< R > ClientReader
Definition: sync_stream.h:56
deadline was reached.
Definition: completion_queue_impl.h:127
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
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue_impl.h:59
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
::grpc_impl::ClientReaderWriter< W, R > ClientReaderWriter
Definition: sync_stream.h:69
Got a new event; tag will be filled in with its associated value; ok indicating its success.
Definition: completion_queue_impl.h:125
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue_impl.h:93
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
grpc_completion_queue * cq()
Returns a raw pointer to the underlying grpc_completion_queue instance.
Definition: completion_queue_impl.h:243
virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)=0
Analogous to struct timespec.
Definition: gpr_types.h:47
NextStatus
Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
Definition: completion_queue_impl.h:123
::grpc_impl::internal::ErrorMethodHandler< code > ErrorMethodHandler
Definition: method_handler.h:62
virtual void grpc_completion_queue_shutdown(grpc_completion_queue *cq)=0
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:539
No event before timeout.
Definition: grpc_types.h:523
ServerCompletionQueue()
Default constructor.
Definition: completion_queue_impl.h:430
::grpc_impl::internal::ClientStreamingHandler< ServiceType, RequestType, ResponseType > ClientStreamingHandler
Definition: method_handler.h:41
A wrapper class of an application provided server streaming handler.
Definition: byte_buffer.h:42
If you are trying to use CompletionQueue::AsyncNext with a time class that isn't either gpr_timespec ...
Definition: time.h:40
::grpc_impl::ServerBuilder ServerBuilder
Definition: server_builder.h:26
::grpc_impl::Channel Channel
Definition: channel.h:26
CompletionQueue(const grpc_completion_queue_attributes &attributes)
Private constructor of CompletionQueue only visible to friend classes.
Definition: completion_queue_impl.h:247
The completion queue has been shutdown and fully-drained.
Definition: completion_queue_impl.h:124
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_impl.h:216