selectme
A fast and fair select! implementation for asynchronous programming.
See the select! or inline! macros for documentation.
Usage
Add the following to your Cargo.toml
:
= "0.4.4"
Examples
The following is a simple example showcasing two branches being polled concurrently. For more documentation see select!.
async ! ;
async
select
The inline!
macro
The inline! macro provides an inlined variant of the select! macro.
Instead of awaiting directly it evaluates to an instance of the Select or StaticSelect allowing for more efficient multiplexing and complex control flow.
When combined with the static;
option it performs the least amount of
magic possible to multiplex multiple asynchronous operations making it
suitable for efficient and custom abstractions.
use Duration;
use time;
async
let output = inline! .await;
match output
The more interesting trick is producing a StaticSelect through the
static;
option which can be properly named and used inside of another
future.
use Future;
use Pin;
use ;
use Duration;
use pin_project;
use StaticSelect;
use ;
let s1 = sleep;
let s2 = sleep;
let my_future = MyFuture ;
assert_eq!;
License: MIT/Apache-2.0