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 Descriptionimpl
std::shared_ptr< internal::CompletionQueueImpl >
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 Descriptionvoid
Shutdown()
Terminate the completion queue event loop.
Returns Type Descriptionvoid
CancelAll()
Cancel all pending operations.
Returns Type Descriptionvoid
MakeDeadlineTimer(std::chrono::system_clock::time_point)
Create a timer that fires at deadline
.
deadline
std::chrono::system_clock::time_point
when should the timer expire.
Returns Type Descriptiongoogle::cloud::future< StatusOr< std::chrono::system_clock::time_point > >
a future that becomes satisfied after deadline
. The result of the future is the time at which it expired, or an error Status if the timer did not run to expiration (e.g. it was cancelled).
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 > >
a future that becomes satisfied after duration
time has elapsed. The result of the future is the time at which it expired, or an error Status if the timer did not run to expiration (e.g. it was cancelled).
Make an asynchronous unary RPC.
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.
typename AsyncCallType
the type of async_call. It must be invocable with (grpc::ClientContext*, Request 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 Response
the response from the asynchronous RPC.
Returns Type Descriptionfuture< 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's Run() 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 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(Functor &&)
Asynchronously run a functor on a thread Run()
ning the CompletionQueue
.
functor
Functor &&
the functor to call in one of the CompletionQueue's threads.
typename Functor
the type of functor
. It must satisfy std::is_invocable<Functor>
.
void
RunAsync(Functor &&)
Asynchronously run a functor on a thread Run()
ning the CompletionQueue
.
functor
Functor &&
the functor to call in one of the CompletionQueue's threads.
typename Functor
the type of functor
. It must satisfy std::is_invocable<Functor>
.
void
AsyncWaitConnectionReady(std::shared_ptr< grpc::Channel >, std::chrono::system_clock::time_point)
Asynchronously wait for a connection to become ready.
Parameters Name Descriptionchannel
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
Returns Type Descriptionfuture< Status >
future<>
which will be satisfied when either of these events happen: (a) the connection is ready, (b) the connection permanently failed, (c) deadline passes before (a) or (b) happen; the future will be satisfied with StatusCode::kOk
for (a), StatusCode::kCancelled
for (b) and StatusCode::kDeadlineExceeded
for (c)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This page details the `CompletionQueue` class in version 2.12.0 of the C++ library, which manages asynchronous operation completion and event handling."],["The `CompletionQueue` class supports functions for running an event loop (`Run()`), terminating the event loop (`Shutdown()`), and canceling all pending operations (`CancelAll()`)."],["It provides the ability to create timers with specific deadlines or durations via `MakeDeadlineTimer()` and `MakeRelativeTimer()`, returning futures that are satisfied upon timer expiration."],["The `CompletionQueue` class also supports making asynchronous unary and streaming read RPCs, and running custom functors asynchronously, though the RPC methods are marked as deprecated in favor of client classes' `Async*()` methods."],["`AsyncWaitConnectionReady()` is available to wait for a connection to become ready, with a deadline option, returning a future with the connection status."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4