Operation queue
Rust helpers for synchronizing asynchronous protocol operations.
Queueing operations
An operation is any data structure that implements the QueuedOperation trait.
QueuedOperation implementations can be pushed to the back of an
OperationQueue, and they will be performed once all previous operations have
been performed and a runner is available.
use ;
// The number of operations to push to the queue.
const OPERATION_COUNT: usize = 100;
// The number of parallel runners the queue will start. Each runner performs
// one operation at a time.
const RUNNER_COUNT: usize = 100;
async
Synchronizing futures
This crate also provides helpers for synchronizing futures across operations
that should only run once at a time. These are located in the line_token
module, which requires the line_token feature.
An example in which this module can help is handling authentication failures when sending multiple parallel requests to the same service: one request encountering this kind of failure usually means the other requests will encounter it too, and having each request try to re-authenticate at the same time is wasteful (in the best of cases).
use ;
Running tests
Some tests in this crate rely on tokio's unstable
API.
Therefore, running them requires the --cfg tokio_unstable compiler flag:
$ RUSTFLAGS="--cfg tokio_unstable" cargo test --all-features