Crate tachyonix

Source
Expand description

A very fast asynchronous, multi-producer, single-consumer (MPSC) bounded channel.

This is a no-frills async bounded MPSC channel which only claim to fame is to be extremely fast, without taking any shortcuts on correctness and implementation quality.

§Disconnection

The channel is disconnected automatically once all Senders are dropped or once the Receiver is dropped. It can also be disconnected manually by any Sender or Receiver handle.

Disconnection is signaled by the Result of the sending or receiving operations. Once a channel is disconnected, all attempts to send a message will return an error. However, the receiver will still be able to receive messages already in the channel and will only get a disconnection error once all messages have been received.

§Example

use tachyonix;
use futures_executor::{block_on, ThreadPool};

let pool = ThreadPool::new().unwrap();

let (s, mut r) = tachyonix::channel(3);

block_on( async move {
    pool.spawn_ok( async move {
        assert_eq!(s.send("Hello").await, Ok(()));
    });
     
    assert_eq!(r.recv().await, Ok("Hello"));
});

Structs§

Receiver
The receiving side of a channel.
RecvError
An error returned when an attempt to receive a message asynchronously is unsuccessful.
SendError
An error returned when an attempt to send a message asynchronously is unsuccessful.
Sender
The sending side of a channel.

Enums§

RecvTimeoutError
An error returned when an attempt to receive a message asynchronously with a deadline is unsuccessful.
SendTimeoutError
An error returned when an attempt to send a message asynchronously with a deadline is unsuccessful.
TryRecvError
An error returned when an attempt to receive a message synchronously is unsuccessful.
TrySendError
An error returned when an attempt to send a message synchronously is unsuccessful.

Functions§

channel
Creates a new channel, returning the sending and receiving sides.