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.
transport::ReliableSocket is a private communication channel between one client and one server and cannot be shared. Copy Client to share a single connection across callers and service clients.Close(), CloseBlocking(), is_open(), and copying or destroying a Client are safe from any thread.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(). Public Member Functions | |
| constexpr | Client ()=default |
| Constructs an empty client, which refers to no connection. | |
| Client (const Client &other) | |
| Client & | operator= (const Client &other) |
| Client (Client &&other) noexcept=default | |
| Client & | operator= (Client &&other) noexcept |
| ControlFuture | Close () |
| void | CloseBlocking () |
| bool | is_open () const |
Static Public Member Functions | |
| static ClientFuture | Connect (async2::Dispatcher &dispatcher, Allocator &allocator, transport::ReliableConnector &connector) |
| static ClientFuture | Connect (async2::Dispatcher &dispatcher, Allocator &allocator, transport::ReliableSocket connection) |
Friends | |
| class | ClientFuture |
| class | internal::GeneratedServiceClient |
| struct | internal::CallAccess |
| ControlFuture pw::rpc2::Client::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.
| void pw::rpc2::Client::CloseBlocking | ( | ) |
Close(), but blocks the calling thread until the connection is closed.
|
inlinestatic |
Returns a future that connects to a peer through connector, performs the handshake, and resolves to the connected Client.
The client's connection task is allocated from allocator and runs on dispatcher.
|
inlinestatic |
Returns a future that performs the handshake over an already-connected connection and resolves to the connected Client.
connection is a private channel to one server and cannot be shared with other RPC clients, servers, or readers/writers.
The client's connection task is allocated from allocator and runs on dispatcher.
|
inline |
Returns true if this client refers to a connection that has not been closed.