GRPC C++  0.11.0.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Friends
grpc::CompletionQueue Class Reference

A thin wrapper around grpc_completion_queue (see / src/core/surface/completion_queue.h). More...

#include <completion_queue.h>

Public Types

enum  NextStatus { SHUTDOWN, GOT_EVENT, TIMEOUT }
 Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. More...
 

Public Member Functions

 CompletionQueue ()
 Default constructor. More...
 
 CompletionQueue (grpc_completion_queue *take)
 Wrap take, taking ownership of the instance. More...
 
 ~CompletionQueue () GRPC_OVERRIDE
 Destructor. Destroys the owned wrapped completion queue / instance. More...
 
template<typename T >
NextStatus AsyncNext (void **tag, bool *ok, const T &deadline)
 Read from the queue, blocking up to deadline (or the queue's shutdown). More...
 
bool Next (void **tag, bool *ok)
 Read from the queue, blocking until an event is available or the queue is shutting down. More...
 
void Shutdown ()
 Request the shutdown of the queue. More...
 
grpc_completion_queue * cq ()
 Returns a raw pointer to the underlying grpc_completion_queue instance. More...
 
- Public Member Functions inherited from grpc::GrpcLibrary
 GrpcLibrary ()
 
virtual ~GrpcLibrary ()
 

Friends

template<class R >
class ::grpc::ClientReader
 
template<class W >
class ::grpc::ClientWriter
 
template<class R , class W >
class ::grpc::ClientReaderWriter
 
template<class R >
class ::grpc::ServerReader
 
template<class W >
class ::grpc::ServerWriter
 
template<class R , class W >
class ::grpc::ServerReaderWriter
 
template<class ServiceType , class RequestType , class ResponseType >
class RpcMethodHandler
 
template<class ServiceType , class RequestType , class ResponseType >
class ClientStreamingHandler
 
template<class ServiceType , class RequestType , class ResponseType >
class ServerStreamingHandler
 
template<class ServiceType , class RequestType , class ResponseType >
class BidiStreamingHandler
 
class UnknownMethodHandler
 
class ::grpc::Server
 
class ::grpc::ServerContext
 
template<class InputMessage , class OutputMessage >
Status BlockingUnaryCall (Channel *channel, const RpcMethod &method, ClientContext *context, const InputMessage &request, OutputMessage *result)
 

Detailed Description

A thin wrapper around grpc_completion_queue (see / src/core/surface/completion_queue.h).

Member Enumeration Documentation

Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.

Enumerator
SHUTDOWN 

The completion queue has been shutdown.

GOT_EVENT 

Got a new event; tag will be filled in with its associated value; ok indicating its success.

TIMEOUT 

deadline was reached.

Constructor & Destructor Documentation

grpc::CompletionQueue::CompletionQueue ( )

Default constructor.

Implicitly creates a grpc_completion_queue instance.

grpc::CompletionQueue::CompletionQueue ( grpc_completion_queue *  take)
explicit

Wrap take, taking ownership of the instance.

Parameters
takeThe completion queue instance to wrap. Ownership is taken.
grpc::CompletionQueue::~CompletionQueue ( )

Destructor. Destroys the owned wrapped completion queue / instance.

Member Function Documentation

template<typename T >
NextStatus grpc::CompletionQueue::AsyncNext ( void **  tag,
bool *  ok,
const T &  deadline 
)
inline

Read from the queue, blocking up to deadline (or the queue's shutdown).

Both tag and ok are updated upon success (if an event is available within the deadline). A tag points to an arbitrary location usually employed to uniquely identify an event.

Parameters
tag[out]Upon sucess, updated to point to the event's tag.
ok[out]Upon sucess, true if read a regular event, false otherwise.
deadline[in]How long to block in wait for an event.
Returns
The type of event read.
grpc_completion_queue* grpc::CompletionQueue::cq ( )
inline

Returns a raw pointer to the underlying grpc_completion_queue instance.

Warning
Remember that the returned instance is owned. No transfer of owership is performed.
bool grpc::CompletionQueue::Next ( void **  tag,
bool *  ok 
)
inline

Read from the queue, blocking until an event is available or the queue is shutting down.

Parameters
tag[out]Updated to point to the read event's tag.
ok[out]true if read a regular event, false otherwise.
Returns
true if read a regular event, false if the queue is shutting down.
void grpc::CompletionQueue::Shutdown ( )

Request the shutdown of the queue.

Warning
This method must be called at some point. Once invoked, Next will start to return false and AsyncNext will return NextStatus::SHUTDOWN. Only once either one of these methods does that (that is, once the queue has been drained) can an instance of this class be destroyed.

Friends And Related Function Documentation

template<class R >
friend class ::grpc::ClientReader
friend
template<class R , class W >
friend class ::grpc::ClientReaderWriter
friend
template<class W >
friend class ::grpc::ClientWriter
friend
friend class ::grpc::Server
friend
friend class ::grpc::ServerContext
friend
template<class R >
friend class ::grpc::ServerReader
friend
template<class R , class W >
friend class ::grpc::ServerReaderWriter
friend
template<class W >
friend class ::grpc::ServerWriter
friend
template<class ServiceType , class RequestType , class ResponseType >
friend class BidiStreamingHandler
friend
template<class InputMessage , class OutputMessage >
Status BlockingUnaryCall ( Channel channel,
const RpcMethod method,
ClientContext context,
const InputMessage &  request,
OutputMessage *  result 
)
friend
template<class ServiceType , class RequestType , class ResponseType >
friend class ClientStreamingHandler
friend
template<class ServiceType , class RequestType , class ResponseType >
friend class RpcMethodHandler
friend
template<class ServiceType , class RequestType , class ResponseType >
friend class ServerStreamingHandler
friend
friend class UnknownMethodHandler
friend

The documentation for this class was generated from the following file: