3.11.0-rc 3.10.0 (latest) 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 2.10.1 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 at `deadline`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `deadline` | `std::chrono::system_clock::time_point` when should the timer expire. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `google::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](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1Status) if the timer did not run to expiration (e.g. it was cancelled). |

### MakeRelativeTimer(std::chrono::duration\< Rep, Period \>)

Create a timer that fires after the `duration`.

| **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 `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. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `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](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1Status) if the timer did not run to expiration (e.g. it was cancelled). |

### MakeUnaryRpc(AsyncCallType, Request const \&, std::unique_ptr\< grpc::ClientContext \>)

Make an asynchronous unary RPC.

> [!WARNING]
> **Deprecated:** Applications should have no need to call this function. The libraries provide `Async*()` 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** | **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's [Run()](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue#classgoogle_1_1cloud_1_1CompletionQueue_1a9803235c77d3838d14b81f5200b204c4) member function. However, only one callback in the handler is called at a time.

> [!WARNING]
> **Deprecated:** Applications should have no need to call this function. The libraries provide `Async*()` 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. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::shared_ptr< AsyncOperation >` |   |

### RunAsync(Functor \&\&)

Asynchronously run a functor on a thread [`Run()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue#classgoogle_1_1cloud_1_1CompletionQueue_1a9803235c77d3838d14b81f5200b204c4)ning the [`CompletionQueue`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `functor` | `Functor &&` the functor to call in one of the [CompletionQueue](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue)'s threads. |
| `typename Functor` | the type of `functor`. It must satisfy `std::is_invocable<Functor>`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `void` |   |

### RunAsync(Functor \&\&)

Asynchronously run a functor on a thread [`Run()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue#classgoogle_1_1cloud_1_1CompletionQueue_1a9803235c77d3838d14b81f5200b204c4)ning the [`CompletionQueue`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `functor` | `Functor &&` the functor to call in one of the [CompletionQueue](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue)'s threads. |
| `typename Functor` | the type of `functor`. It must satisfy `std::is_invocable<Functor>`. |

| **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_point` give up waiting for the state change if this deadline passes |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< 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`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a) for (a), [`StatusCode::kCancelled`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847a971493a769ad0aed23946733ede4a8f1) for (b) and [`StatusCode::kDeadlineExceeded`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847a4d40d05ef9a0c7b22fb80d1bbf8a72df) for (c) |