Crate eventual [−] [src]
Composable primitives for asynchronous computations
The async module contains utilities for managing asynchronous computations.
These utilities are primarily based around Future
and Stream
types as
well as functions that allow composing computations on these types.
Future
A Future
is a proxy representing the result of a computation which may
not be complete. The computation may be running concurrently in another
thread or may be triggered upon completion of an asynchronous callback. One
way to think of a Future
is as a Result
where the value is
asynchronously computed.
For example:
use eventual::*; // Run a computation in another thread let future1 = Future::spawn(|| { // Represents an expensive computation, but for now just return a // number 42 }); // Run another computation let future2 = Future::spawn(|| { // Another expensive computation 18 }); let res = join(( future1.map(|v| v * 2), future2.map(|v| v + 5))) .and_then(|(v1, v2)| Ok(v1 - v2)) .await().unwrap(); assert_eq!(61, res);
Stream
A Stream
is like a Future
, except that instead of representing a single
value, it represents a sequence of values.
Structs
BusySender | |
Complete |
An object that is used to fulfill or reject an associated Future. |
Future | |
Receipt | |
Sender |
The sending half of |
Stream | |
StreamIter | |
Timer |
Provides timeouts as a |
Enums
AsyncError |
Traits
Async |
A value representing an asynchronous computation |
Cancel | |
Join | |
Pair | |
Select |
Functions
background |
This method backgrounds a task onto a task runner waiting for complete to be called. Currently we only support using a ThreadPool as the task runner itself. |
defer |
This method defers a task onto a task runner until we can complete that call. Currently we only support using a ThreadPool as the task runner itself. |
join | |
select | |
sequence |
Returns a |
Type Definitions
AsyncResult |