Expand description
Portable interface for various utilities.
Intended targets are:
- native platforms with tokio async runtime,
- WebAssembly targeted to browsers, including WebWorkers, under standard single-threaded model.
Following features are provided:
- Mutex and RwLock (using parking_lot on native platforms and std::cell::RefCell in WASM).
- asynchronous spawn (not requiring Send in WASM) and sleep,
- Timeout future,
- dtest attribute macro to create tests for both native and WASM targets, also dtest_configure macro to configure tests to run in browser.
- create_non_sync_send_variant_for_wasm utility macro for creating non-Send and non-Sync variants of traits for use in WASM.
- random function.
Modules§
- test
- Tests-related macros.
- time
- Utilities for tracking time.
- value
- Asynchronous cloneable lazily-initialized value.
Macros§
- create_
non_ sync_ send_ variant_ for_ wasm - Utility macro for creating non-Send and non-Sync variants of traits for use in WASM.
Structs§
- Join
Error - Task failed to execute to completion.
- Join
Handle - An owned permission to join on a task (await its termination).
Functions§
- random
- Returns a floating-point, pseudo-random number in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution over that range.
- spawn
- Spawns a new asynchronous task, returning a
JoinHandle
for it.
Type Aliases§
- Mutex
- A mutual exclusion primitive useful for protecting shared data
- Mutex
Guard - An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
- RwLock
- A reader-writer lock
- RwLock
Read Guard - RAII structure used to release the shared read access of a lock when dropped.
- RwLock
Write Guard - RAII structure used to release the exclusive write access of a lock when dropped.