#immediate-mode #async #promise #gamedev #poll #gui

poll-promise

Poll the result of an async operation in a game or immediate mode GUI

3 releases (breaking)

0.3.0 Aug 27, 2023
0.2.1 Sep 29, 2023
0.2.0 Oct 24, 2022
0.1.0 Jan 10, 2022

#87 in Asynchronous

Download history 2785/week @ 2024-03-03 3757/week @ 2024-03-10 5857/week @ 2024-03-17 6824/week @ 2024-03-24 4622/week @ 2024-03-31 3839/week @ 2024-04-07 4619/week @ 2024-04-14 7752/week @ 2024-04-21 4958/week @ 2024-04-28 3210/week @ 2024-05-05 5121/week @ 2024-05-12 4747/week @ 2024-05-19 7595/week @ 2024-05-26 5792/week @ 2024-06-02 4421/week @ 2024-06-09 4385/week @ 2024-06-16

22,399 downloads per month
Used in 10 crates (7 directly)

MIT/Apache

37KB
539 lines

poll-promise

A Rust promise for games and immediate mode GUIs

Embark Embark Crates.io Docs dependency status Build status

Description

poll-promise is a Rust crate for polling the result of a concurrent (e.g. async) operation. This is in particular 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 = poll_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 icon
}

If you enable the tokio feature you can use poll-promise with the tokio runtime.

Caveat

The crate is primarily useful as a high-level building block in apps.

This crate provides convenience methods to spawn threads and tokio tasks, and methods that block on waiting for a result. This is gererally a bad idea to do in a library, as decisions about execution environments and thread blocking should be left to the app. So we do not recommend using this crate for libraries in its current state.

See also

Similar functionality is provided by:

Contribution

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started. Please also read our Contributor Terms before you make any contributions.

Any contribution intentionally submitted for inclusion in an Embark Studios project, shall comply with the Rust standard licensing model (MIT OR Apache 2.0) and therefore be dual licensed as described below, without any additional terms or conditions:

License

This contribution is dual licensed under EITHER OF

at your option.

For clarity, "your" refers to Embark or any other licensee/user of the contribution.

Dependencies

~0.2–12MB
~133K SLoC