GitXplorerGitXplorer
D

wasm_main_executor

public
4 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
a2ee83a020e34adca8a8718f5076dd4f24bf3886

Add docs and fix compilation errors

DDouglasDwyer committed 2 years ago
Unverified
ccb291afde45f1376a64513526dfbc6a1058cde9

Fix issues add README.md

DDouglasDwyer committed 2 years ago
Unverified
b3c69b44e095fc8842c86b5ea11c61da53c10249

Improve polling

DDouglasDwyer committed 2 years ago
Unverified
a7ba43543cf5923eef964690a63a0b7359ec23f8

Fix small potential race condition

DDouglasDwyer committed 2 years ago
Unverified
97043455eaab2f51d28c9c9e4f97052ee1f84ac6

Update lib.rs

DDouglasDwyer committed 2 years ago
Unverified
3e91a48cbf8475aa7096a1031b42b9ecebff3fd4

Initial commit

DDouglasDwyer committed 2 years ago

README

The README file for this repository.

wasm_main_executor

Run futures on the main browser thread

Crates.io Docs.rs

Certain tasks, like creating an AudioContext or RtcPeerConnection, can only be performed on the main browser thread. wasm_main_executor provides an easy way to send futures to the main browser thread from any context. This allows web workers to spawn main-threaded tasks and await their completion, and facilitates the implementation of cross-thread polyfills/shims.

Usage

The following is a simple example of executor usage:

async fn test_future() -> i32 {
    // Do some async or main-threaded work...
    2
}

// Start the executor. This must be called from the main browser thread.
wasm_main_executor::initialize().unwrap();

// Futures may be spawned on background threads using the executor.
// The future runs on the main thread.
let fut = wasm_main_executor::spawn(test_future());

// A future is returned which may be awaited on the background thread.
assert_eq!(2, futures::executor::block_on(fut));