Method in task · Channel compiler

Channel::try_send

pub fn try_send(T value) -> Result<unit, ChannelError>
Import
use task::{Channel};
Source: compiler/src/prelude/task.hy

Adds value if there is room, without waiting.

Called on a Channel value as value.try_send(…).

Parameters#

NameType
valueT

Returns#

Result<unit, ChannelError>

Errors#

Err(ChannelError::Full) when the channel is full and Err(ChannelError::Closed) once it is closed.

See also#

  • Channel: A bounded queue for passing values between tasks.
  • Channel::send: Adds value to the channel, waiting while it is full (a suspension point).
  • Channel::recv: Takes the oldest value, waiting while the channel is empty (a suspension point).
  • Channel::try_recv: Takes the oldest value if there is one, without waiting.
  • Channel::close: Closes the channel: no more values can be sent.
  • Channel::len: Returns the number of values waiting to be received.
  • Channel::capacity: Returns the most values the channel can hold.
  • Channel::is_closed: Returns true once close has been called.
↑ ↓ navigate ↵ open