Shared handle to an established RPC connection.
A Client refers to the connection it was created from: closing it closes the transport and cancels every call on it. Client is cheaply copyable, and all copies refer to the same underlying connection. Service clients wrap a Client and bind it to a service ID.
- Note
- Threading. Everything reachable through a client — its calls, their handles, and their futures — is bound to the dispatcher the client was created on and may only be used from that dispatcher's thread. Exceptions:
Close(), CloseBlocking(), is_open(), and copying or destroying a Client are safe from any thread.
-
Closing. Destroying the last copy of a
Client (including copies held by service clients) closes the connection and cancels its in-flight calls. The close happens asynchronously on the dispatcher. To be sure it has finished before destroying the dispatcher or allocator, call CloseBlocking() or await Close().
Closes the connection shared by this client and all its copies, completing every call on it with kClosed, and releases this client's handle to the connection. The returned future resolves to kOk once the dispatcher has torn the connection down, or immediately if the client is empty or already closed.
Call handles and futures still held by the user stay valid but inert until destroyed.