Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. pw_rpc2
  5. Readers and writers
  6. pw::rpc2::ResponseFuture< Response > Class Template Reference
Loading...
Searching...
No Matches
pw::rpc2::ResponseFuture< Response > Class Template Reference

Overview

template<typename Response = ConstBuf>
class pw::rpc2::ResponseFuture< Response >

Future that resolves to the server's single response to a client unary or client-streaming RPC (RpcResult<Response>).

Returned by UnaryReservation::Commit() and ClientStreamCall::response(). UnaryFuture uses one internally.

A ResponseFuture is its call's only reader. Destroying it before it resolves cancels the call (kCancelled) so the server can stop work. Cancel() does the same while keeping the future, which then resolves to kCancelled.

Inheritance diagram for pw::rpc2::ResponseFuture< Response >:
pw::rpc2::internal::ResponseFutureBase pw::rpc2::internal::ReadFutureBase pw::rpc2::internal::FutureBase

Public Types

using value_type = RpcResult< Response >
 

Public Member Functions

 ResponseFuture (const ResponseFuture &)=delete
 
ResponseFuture & operator= (const ResponseFuture &)=delete
 
 ResponseFuture (ResponseFuture &&) noexcept=default
 
ResponseFuture & operator= (ResponseFuture &&) noexcept=default
 
async2::Poll< RpcResult< Response > > Pend (async2::Context &cx)
 
- Public Member Functions inherited from pw::rpc2::internal::ResponseFutureBase
void Cancel ()
 
- Public Member Functions inherited from pw::rpc2::internal::ReadFutureBase
 ReadFutureBase (const ReadFutureBase &)=delete
 
ReadFutureBase & operator= (const ReadFutureBase &)=delete
 
- Public Member Functions inherited from pw::rpc2::internal::FutureBase
 FutureBase (const FutureBase &)=delete
 
FutureBase & operator= (const FutureBase &)=delete
 
constexpr bool is_pendable () const
 
constexpr bool is_complete () const
 

Friends

struct internal::CallAccess
 

Additional Inherited Members

- Protected Member Functions inherited from pw::rpc2::internal::ResponseFutureBase
 ResponseFutureBase (IntrusivePtr< Call > &&call)
 
 ResponseFutureBase (ResponseFutureBase &&) noexcept=default
 
ResponseFutureBase & operator= (ResponseFutureBase &&) noexcept=default
 
- Protected Member Functions inherited from pw::rpc2::internal::ReadFutureBase
 ReadFutureBase (const IntrusivePtr< Call > &call)
 
 ReadFutureBase (IntrusivePtr< Call > &&call)
 
 ReadFutureBase (ReadFutureBase &&other) noexcept=default
 
ReadFutureBase & operator= (ReadFutureBase &&other) noexcept
 
async2::Poll< RpcResult< ConstBuf > > PendRaw (async2::Context &cx)
 
void PendAndDeserialize (async2::Context &cx, void *result_out, DeserializeFn deserialize)
 
- Protected Member Functions inherited from pw::rpc2::internal::FutureBase
constexpr FutureBase (async2::FutureState::Pending)
 
constexpr FutureBase (async2::FutureState state)
 
constexpr FutureBase (FutureBase &&) noexcept=default
 
constexpr FutureBase & operator= (FutureBase &&) noexcept=default
 
constexpr void mark_pending ()
 
void mark_complete ()
 

Member Function Documentation

◆ Pend()

template<typename Response = ConstBuf>
async2::Poll< RpcResult< Response > > pw::rpc2::ResponseFuture< Response >::Pend ( async2::Context &  cx)
inline

Polls for the server's response.

Returns
  • kOk with the decoded Response (or raw ConstBuf) once the server replies.
  • kDataError if the response could not be decoded as Response, or the server could not decode the request.
  • The status that ended the call, if it ended with an error: for example, kCancelled if either end cancelled the RPC; kClosed, kDisconnected, or kProtocolError if the connection closed; or kUnimplemented, kUnavailable, kAborted, or kProtocolError if the server ended the call. See Error handling.

The documentation for this class was generated from the following file: