Skip to main content

Module oneshot

Module oneshot 

Source
Expand description

A oneshot channel whose receiver blocks the calling OS thread.

This is the synchronous analogue of tokio::sync::oneshot, for code that must wait for a value produced elsewhere without being async (e.g. execution threads blocking until an object version is committed). It is a thin wrapper over the [oneshot] crate that adds a Receiver::blocking_recv tailored to Sui’s execution model:

  • The wait always begins with a non-blocking try_recv, so a value that is already available is returned without any side effects.
  • If it must block, it first releases the thread’s execution permit so other execution can proceed (see that module for the deadlock rationale).
  • Under msim, parking the OS thread would hang the single-threaded simulator, so it instead polls in a loop, yielding the simulated thread quantum between checks. This would busy-wait on a real system, but the simulator only wakes the thread at a controlled rate, and only blocking-pool threads may wait this way.

Structs§

Receiver
RecvError
Error returned by blocking_recv when the sender was dropped without sending.
Sender

Enums§

TryRecvError
Error returned by try_recv when no value is available.

Functions§

channel
Create a new oneshot channel.