Crate poll_promise

source ·
Expand description

poll-promise is a Rust crate for polling the result of a concurrent (e.g. async) operation.

It is particularly useful in games and immediate mode GUI:s, where one often wants to start a background operation and then ask “are we there yet?” on each subsequent frame until the operation completes.

Example:

let promise = Promise::spawn_thread("slow_operation", something_slow);

// Then in the game loop or immediate mode GUI code:
if let Some(result) = promise.ready() {
    // Use/show result
} else {
    // Show a loading screen
}

Features

poll-promise can be used with any async runtime (or without one!), but a few convenience methods are added when compiled with the following features:

Structs

  • A promise that waits for the reception of a single value, presumably from some async task.
  • Used to send a result to a Promise.

Enums

Functions

  • ticksmol
    ‘Tick’ the smol thread executor.
  • ‘Tick’ the smol local thread executor.