async-oneshot 0.3.0

A fast, small, full-featured async-aware oneshot channel.
Documentation
async-oneshot-0.3.0 has been yanked.

async-oneshot

License Package Documentation

A fast and small async-aware oneshot channel.

Features:

  • Sender may wait for a receiver to be waiting.
  • Fast and small, with easy to understand code.
  • Only two dependencies, both mine and with no deps.
  • Complete no_std support (with alloc for Arc).

Usage

#[test]
fn success_one_thread() {
    let (s,r) = oneshot::<bool>();
    assert_eq!((), s.send(true).unwrap());
    assert_eq!(Ok(true), future::block_on(r));
}

Performance

Crap numbers from my shitty 2015 macbook pro:

test create                ... bench:         122 ns/iter (+/- 12)
test create_send           ... bench:         122 ns/iter (+/- 21)
test create_send_recv      ... bench:         126 ns/iter (+/- 8)
test create_wait_send_recv ... bench:         232 ns/iter (+/- 29)

The measurement overhead seems to be a huge part of these times.

Note on safety

Yes, this crate uses unsafe. 10 times. Not all of it is performance gaming. Please audit carefully!

See Also

Copyright and License

Copyright (c) 2020 James Laver, async-oneshot contributors.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.