Crate uexec

Source
Expand description

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();

Structs§

  • Wait for a spawned task to complete or cancel it.
  • Wait for a spawned local task to complete or cancel it.

Functions§

  • Runs the global and the local executor on the current thread until the given future is Ready
  • Spawns a task onto the multi-threaded global executor.
  • Spawns a task onto the local executor.
  • Spawn new worker threads
  • Terminate all worker threads