Class CompletionQueue (2.46.0-rc) Stay organized with collections Save and categorize content based on your preferences.
Call the functor associated with asynchronous operations when they complete.
Constructors
CompletionQueue()
CompletionQueue(std::shared_ptr< internal::CompletionQueueImpl >)
| Parameter | |
|---|---|
| Name | Description |
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.
| Returns | |
|---|---|
| Type | Description |
void | |
Shutdown()
Terminate the completion queue event loop.
| Returns | |
|---|---|
| Type | Description |
void | |
CancelAll()
Cancel all pending operations.
| Returns | |
|---|---|
| Type | Description |
void | |
MakeDeadlineTimer(std::chrono::system_clock::time_point)
Create a timer that fires atdeadline.
| Parameter | |
|---|---|
| Name | Description |
deadline | std::chrono::system_clock::time_pointwhen should the timer expire. |
| Returns | |
|---|---|
| Type | Description |
google::cloud::future< StatusOr< std::chrono::system_clock::time_point > > | a future that becomes satisfied after |
MakeRelativeTimer(std::chrono::duration< Rep, Period >)
Create a timer that fires after theduration.
| Parameters | |
|---|---|
| Name | Description |
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 |
typename Period | a placeholder to match the Period tparam for |
| Returns | |
|---|---|
| Type | Description |
future< StatusOr< std::chrono::system_clock::time_point > > | a future that becomes satisfied after |
MakeUnaryRpc(AsyncCallType, Request const &, std::unique_ptr< grpc::ClientContext >)
Make an asynchronous unary RPC.
| Parameters | |
|---|---|
| Name | Description |
async_call | AsyncCallTypea 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 ofasync_call. It must be invocable with |
typename Request | the type of the request parameter in the gRPC. |
typename Response | the response from the asynchronous RPC. |
| Returns | |
|---|---|
| Type | Description |
future< StatusOr< Response > > | a future that becomes satisfied when the operation completes. |
MakeStreamingReadRpc(AsyncCallType &&, Request const &, std::unique_ptr< grpc::ClientContext >, OnReadHandler &&, OnFinishHandler &&)
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'sRun() member function. However, only one callback in the handler is called at a time.
Deprecated:Applications should have no need to call this function. The libraries provideAsync*() member functions in the generated (or) hand-crafted*Client classes for the same purpose.| Parameters | |
|---|---|
| Name | Description |
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 ofasync_call. It must be invocable with parameters |
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 |
typename OnFinishHandler | the type of the |
| Returns | |
|---|---|
| Type | Description |
std::shared_ptr< AsyncOperation > | |
RunAsync(Functor &&)
Asynchronously run a functor on a threadRun()ning theCompletionQueue.
| Parameters | |
|---|---|
| Name | Description |
functor | Functor &&the functor to call in one of theCompletionQueue's threads. |
typename Functor | the type of |
| Returns | |
|---|---|
| Type | Description |
void | |
RunAsync(Functor &&)
Asynchronously run a functor on a threadRun()ning theCompletionQueue.
| Parameters | |
|---|---|
| Name | Description |
functor | Functor &&the functor to call in one of theCompletionQueue's threads. |
typename Functor | the type of |
| Returns | |
|---|---|
| Type | Description |
void | |
AsyncWaitConnectionReady(std::shared_ptr< grpc::Channel >, std::chrono::system_clock::time_point)
Asynchronously wait for a connection to become ready.
| Parameters | |
|---|---|
| Name | Description |
channel | std::shared_ptr< grpc::Channel >the channel on which to wait for state changes |
deadline | std::chrono::system_clock::time_pointgive up waiting for the state change if this deadline passes |
| Returns | |
|---|---|
| Type | Description |
future< Status > |
|
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.