heph icon indicating copy to clipboard operation
heph copied to clipboard

Add rpc::all function

Open Thomasdezeeuw opened this issue 2 years ago • 0 comments

Goals:

  • Minimal number of wakeups of the caller (ideally only 1 when all calls have return or errored).
  • Minimal amount of allocations.

API idea

/// Run multple RPCs concurrently.
fn all<I, Res>(rpc: I) -> Res
where
    I: ExactSizeIterator<RPC<T>>,
    Res: FromIterator<Result<T, SendError>>,
{
    // ...
}

Specially design task::Waker implementation that only wakes if all responses are ready, or if one errored (?). Waker called:

  • If message not yet send -> wake to send message.
  • If message is already send -> don't wake, mark the message as ready to receive.

Thomasdezeeuw avatar Apr 16 '22 17:04 Thomasdezeeuw