Call the functor associated with asynchronous operations when they complete.
Constructors
CompletionQueue
CompletionQueue
impl
std::shared_ptr< internal::CompletionQueueImpl >
Functions
Run
Run the completion queue event loop.
Note that more than one thread can call this member function, to create a pool of threads completing asynchronous operations.
void
Shutdown
Terminate the completion queue event loop.
void
CancelAll
Cancel all pending operations.
void
MakeDeadlineTimer
Create a timer that fires at deadline
.
deadline
std::chrono::system_clock::time_point
when should the timer expire.
google::cloud::future< StatusOr< std::chrono::system_clock::time_point > >
MakeRelativeTimer
Create a timer that fires after the duration
.
duration
std::chrono::duration< Rep, Period >
when should the timer expire relative to the current time.
typename Rep
a placeholder to match the Rep tparam for duration
type, the semantics of this template parameter are documented in std::chrono::duration<>
(in brief, the underlying arithmetic type used to store the number of ticks), for our purposes it is simply a formal parameter.
typename Period
a placeholder to match the Period tparam for duration
type, the semantics of this template parameter are documented in std::chrono::duration<>
(in brief, the length of the tick in seconds, expressed as a std::ratio<>
), for our purposes it is simply a formal parameter.
future< StatusOr< std::chrono::system_clock::time_point > >
MakeUnaryRpc
Make an asynchronous unary RPC.
async_call
AsyncCallType
a callable to start the asynchronous RPC.
request
Request const &
the contents of the request.
context
std::unique_ptr< grpc::ClientContext >
an initialized request context to make the call.
typename AsyncCallType
the type of async_call
. It must be invocable with (grpc::ClientContext*, RequestType const&, grpc::CompletionQueue*)
. Furthermore, it should return a std::unique_ptr<grpc::ClientAsyncResponseReaderInterface<Response>>>
. These requirements are verified by internal::CheckAsyncUnaryRpcSignature<>
, and this function is excluded from overload resolution if the parameters do not meet these requirements.
typename Request
the type of the request parameter in the gRPC.
typename Sig
typename Response
typename std::enable_if< sig::value,="" int="">::type
future< StatusOr< Response > >
MakeStreamingReadRpc
Make an asynchronous streaming read RPC.
Reading from the stream starts automatically, and the handler is notified of all interesting events in the stream. Note that then handler is called by any thread blocked on this object's Run() member function. However, only one callback in the handler is called at a time.
async_call
AsyncCallType &&
a callable to start the asynchronous RPC.
request
Request const &
the contents of the request.
context
std::unique_ptr< grpc::ClientContext >
an initialized request context to make the call.
on_read
OnReadHandler &&
the callback to be invoked on each successful Read().
on_finish
OnFinishHandler &&
the callback to be invoked when the stream is closed.
typename AsyncCallType
the type of async_call
. It must be invocable with parameters (grpc::ClientContext*, RequestType const&, grpc::CompletionQueue*)
. Furthermore, it should return a type convertible to std::unique_ptr<grpc::ClientAsyncReaderInterface<Response>>>
. These requirements are verified by internal::AsyncStreamingReadRpcUnwrap<>
, and this function is excluded from overload resolution if the parameters do not meet these requirements.
typename Request
the type of the request in the streaming RPC.
typename Response
the type of the response in the streaming RPC.
typename OnReadHandler
the type of the on_read
callback.
typename OnFinishHandler
the type of the on_finish
callback.
std::shared_ptr< AsyncOperation >
RunAsync
Asynchronously run a functor on a thread Run()
ning the CompletionQueue
.
functor
Functor &&
the value of the functor.
typename Functor
typename std::enable_if<>< functor="">::value, int >::type
void
RunAsync
Asynchronously run a functor on a thread Run()
ning the CompletionQueue
.
functor
Functor &&
the value of the functor.
typename Functor
typename std::enable_if<>< functor="">::value, int >::type
void
AsyncWaitConnectionReady
Asynchronously wait for a connection to become ready.
channel
std::shared_ptr< grpc::Channel >
the channel on which to wait for state changes
deadline
std::chrono::system_clock::time_point
give up waiting for the state change if this deadline passes
future< Status >

