Crate uexec[][src]

uexec - simple work-stealing global and local executor

The global executor is lazily spawned on first use. It doesn’t spawn any worker threads by default but you can use spawn_workers to do that.

Examples


// spawn several worker threads
uexec::spawn_workers(4);

// spawn a task on the multi-threaded executor
let task1 = uexec::spawn(async {
    1 + 2
});
// spawn a task on the local executor (same thread)
let task2 = uexec::spawn_local(async {
    3 + 4
});
let task = future::zip(task1, task2);

// run the executor
uexec::block_on(async {
    assert_eq!(task.await, (3, 7));
});

// terminate our worker threads
uexec::terminate_workers();

Functions

block_on

Runs the global and the local executor on the current thread until the given future is Ready

spawn

Spawns a task onto the multi-threaded global executor.

spawn_local

Spawns a task onto the local executor.

spawn_workers

Spawn new worker threads

terminate_workers

Terminate all worker threads