Google Cloud Bigtable C++ Client  0.11.0
A C++ Client Library for Google Cloud Bigtable
Public Member Functions | List of all members
google::cloud::bigtable::v0::CompletionQueue Class Reference

Call the functor associated with asynchronous operations when they complete. More...

#include <google/cloud/bigtable/completion_queue.h>

Public Member Functions

 CompletionQueue ()
 
 CompletionQueue (std::shared_ptr< internal::CompletionQueueImpl > impl)
 
void Run ()
 Run the completion queue event loop. More...
 
void Shutdown ()
 Terminate the completion queue event loop. More...
 
google::cloud::future< std::chrono::system_clock::time_point > MakeDeadlineTimer (std::chrono::system_clock::time_point deadline)
 Create a timer that fires at deadline. More...
 
template<typename Rep , typename Period >
future< std::chrono::system_clock::time_point > MakeRelativeTimer (std::chrono::duration< Rep, Period > duration)
 Create a timer that fires after the duration. More...
 
template<typename AsyncCallType , typename Request , typename Sig = internal::AsyncCallResponseType<AsyncCallType, Request>, typename Response = typename Sig::type, typename std::enable_if< Sig::value, int >::type = 0>
future< StatusOr< Response > > MakeUnaryRpc (AsyncCallType async_call, Request const &request, std::unique_ptr< grpc::ClientContext > context)
 Make an asynchronous unary RPC. More...
 
template<typename AsyncCallType , typename Request , typename Response = typename internal:: AsyncStreamingReadResponseType<AsyncCallType, Request>::type, typename OnReadHandler , typename OnFinishHandler >
std::shared_ptr< AsyncOperationMakeStreamingReadRpc (AsyncCallType &&async_call, Request const &request, std::unique_ptr< grpc::ClientContext > context, OnReadHandler &&on_read, OnFinishHandler &&on_finish)
 Make an asynchronous streaming read RPC. More...
 
template<typename Functor , typename std::enable_if< internal::CheckRunAsyncCallback< Functor >::value, int >::type = 0>
void RunAsync (Functor &&functor)
 Asynchronously run a functor on a thread Run()ning the CompletionQueue. More...
 

Detailed Description

Call the functor associated with asynchronous operations when they complete.

Definition at line 31 of file completion_queue.h.

Constructor & Destructor Documentation

◆ CompletionQueue() [1/2]

google::cloud::bigtable::v0::CompletionQueue::CompletionQueue ( )

Definition at line 77 of file completion_queue.cc.

◆ CompletionQueue() [2/2]

google::cloud::bigtable::v0::CompletionQueue::CompletionQueue ( std::shared_ptr< internal::CompletionQueueImpl >  impl)
inlineexplicit

Definition at line 34 of file completion_queue.h.

Member Function Documentation

◆ MakeDeadlineTimer()

google::cloud::future< std::chrono::system_clock::time_point > google::cloud::bigtable::v0::CompletionQueue::MakeDeadlineTimer ( std::chrono::system_clock::time_point  deadline)

Create a timer that fires at deadline.

Parameters
deadlinewhen should the timer expire.
Returns
a future that becomes satisfied after deadline.

Definition at line 84 of file completion_queue.cc.

◆ MakeRelativeTimer()

template<typename Rep , typename Period >
future<std::chrono::system_clock::time_point> google::cloud::bigtable::v0::CompletionQueue::MakeRelativeTimer ( std::chrono::duration< Rep, Period >  duration)
inline

Create a timer that fires after the duration.

Template Parameters
Repa 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.
Perioda 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.
Parameters
durationwhen should the timer expire relative to the current time.
Returns
a future that becomes satisfied after duration time has elapsed.

Definition at line 77 of file completion_queue.h.

◆ MakeStreamingReadRpc()

template<typename AsyncCallType , typename Request , typename Response = typename internal:: AsyncStreamingReadResponseType<AsyncCallType, Request>::type, typename OnReadHandler , typename OnFinishHandler >
std::shared_ptr<AsyncOperation> google::cloud::bigtable::v0::CompletionQueue::MakeStreamingReadRpc ( AsyncCallType &&  async_call,
Request const &  request,
std::unique_ptr< grpc::ClientContext >  context,
OnReadHandler &&  on_read,
OnFinishHandler &&  on_finish 
)
inline

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.

Parameters
async_calla callable to start the asynchronous RPC.
requestthe contents of the request.
contextan initialized request context to make the call.
on_readthe callback to be invoked on each successful Read().
on_finishthe callback to be invoked when the stream is closed.
Template Parameters
AsyncCallTypethe 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.
Requestthe type of the request in the streaming RPC.
Responsethe type of the response in the streaming RPC.
OnReadHandlerthe type of the on_read callback.
OnFinishHandlerthe type of the on_finish callback.

Definition at line 148 of file completion_queue.h.

◆ MakeUnaryRpc()

template<typename AsyncCallType , typename Request , typename Sig = internal::AsyncCallResponseType<AsyncCallType, Request>, typename Response = typename Sig::type, typename std::enable_if< Sig::value, int >::type = 0>
future<StatusOr<Response> > google::cloud::bigtable::v0::CompletionQueue::MakeUnaryRpc ( AsyncCallType  async_call,
Request const &  request,
std::unique_ptr< grpc::ClientContext >  context 
)
inline

Make an asynchronous unary RPC.

Parameters
async_calla callable to start the asynchronous RPC.
requestthe contents of the request.
contextan initialized request context to make the call.
Template Parameters
AsyncCallTypethe 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.
Requestthe type of the request parameter in the gRPC.
Returns
a future that becomes satisfied when the operation completes.

Definition at line 106 of file completion_queue.h.

◆ Run()

void google::cloud::bigtable::v0::CompletionQueue::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.

Definition at line 79 of file completion_queue.cc.

◆ RunAsync()

template<typename Functor , typename std::enable_if< internal::CheckRunAsyncCallback< Functor >::value, int >::type = 0>
void google::cloud::bigtable::v0::CompletionQueue::RunAsync ( Functor &&  functor)
inline

Asynchronously run a functor on a thread Run()ning the CompletionQueue.

Template Parameters
Functorthe functor to call on the CompletionQueue thread. It must satisfy the void(CompletionQueue&) signature.
Parameters
functorthe value of the functor.
Returns
an asynchronous operation wrapping the functor; it can be used for cancelling but it makes little sense given that it will be completed straight away

Definition at line 173 of file completion_queue.h.

◆ Shutdown()

void google::cloud::bigtable::v0::CompletionQueue::Shutdown ( )

Terminate the completion queue event loop.

Definition at line 81 of file completion_queue.cc.