tokio/tokio-sync/tests/atomic_task.rs
Carl Lerche 13083153aa
Introduce tokio-sync crate containing synchronization primitives. (#839)
Introduce a tokio-sync crate containing useful synchronization primitives for programs
written using Tokio.

The initial release contains:

* An mpsc channel
* A oneshot channel
* A semaphore implementation
* An `AtomicTask` primitive.

The `oneshot` and `mpsc` channels are new implementations providing improved
performance characteristics. In some benchmarks, the new mpsc channel shows
up to 7x improvement over the version provided by the `futures` crate. Unfortunately,
the `oneshot` implementation only provides a slight performance improvement as it
is mostly limited by the `futures` 0.1 task system. Once updated to the `std` version
of `Future` (currently nightly only), much greater performance improvements should
be achievable by `oneshot`.

Additionally, he implementations provided here are checked using
[Loom](http://github.com/carllerche/loom/), which provides greater confidence of
correctness.
2019-01-22 11:37:26 -08:00

15 lines
286 B
Rust

extern crate futures;
extern crate tokio_sync;
use futures::task::Task;
use tokio_sync::task::AtomicTask;
trait AssertSend: Send {}
trait AssertSync: Send {}
impl AssertSend for AtomicTask {}
impl AssertSync for AtomicTask {}
impl AssertSend for Task {}
impl AssertSync for Task {}