Expand description
§atask
atask is a flexible task model for building async executors.
First, create a queue to hold the scheduled tasks.
let (sender, reciever) = flume::unbounded();A task is spawned using a spawn* function.
let future = async { "hewwo" };
let schedule = move |runnable| sender.send(runnable).unwrap();
let (runnable, handle) = atask::spawn(future);
runnable.schedule();Finally, the spawned tasks must be polled.
for runnable in receiver {
runnable.run();
}§Differences from async-task
async-task is a very similar library with a few key differences.
The primary differences are:
- Cancelling or detaching a task does not consume the handle.
- Tasks are detached rather than consumed on dropping the handle.
§Cargo features
std(default): Enables the use of the standard library and enables thespawn_localmessages.
Structs§
- Abort
Handle - A handle to cancel a task.
- Builder
- A builder for a task.
- Join
Handle - A handle to a running task.
- Runnable
- A task which can be run or scheduled.
- Schedule
Info - Internally-generated information passed to the scheduler.
- With
Info - A scheduler that receives extra information.
Enums§
- Error
- An error returned from a failed task.
Traits§
- Schedule
- A task scheduler.
Functions§
- spawn
- Spawn a task to run on an executor.
- spawn_
local std - Spawn a task to run on the same thread it was spawned.
- spawn_
unchecked ⚠ - Spawn a task to run on an executor.
Type Aliases§
- Result
- A result returned from a task.