Expand description
Platform-aware primitives for native and wasm32 targets.
§Synchronization
Re-exports sync primitives (Mutex, Condvar, RwLock, mpsc)
backed by parking_lot / std on native and [wasm_safe_thread] on WASM.
§Async tasks
tokio::task module: tokio::task::spawn,
tokio::task::spawn_blocking, tokio::task::yield_now.
§Conditional trait bounds
MaybeSend and MaybeSync are conditional trait bounds:
on native they equal Send/Sync, on wasm32 they are blanket-implemented
for all types. Use in trait bounds to avoid duplicating trait definitions
with #[cfg] gates.
§Async utilities
time::sleep delegates to tokio::time::sleep on native and to
setTimeout on wasm32.
Re-exports§
pub use sync::Condvar;pub use sync::Mutex;pub use sync::MutexGuard;pub use sync::NotAvailable;pub use sync::RwLock;pub use sync::RwLockReadGuard;pub use sync::RwLockWriteGuard;pub use thread::JoinHandle;pub use thread::Thread;pub use thread::ThreadId;pub use thread::current;pub use thread::park;pub use thread::park_timeout;pub use thread::sleep;pub use thread::spawn;
Modules§
- sync
- Platform-optimal synchronization primitives.
- thread
- time
- tokio
- Cross-platform tokio — real
tokioon native, WASM shims onwasm32.
Structs§
- Cancel
Group - OR-combinator for cancellation tokens.
- Duration
- A
Durationtype to represent a span of time, typically used for system timeouts. - Wasm
Send - Wrapper that unconditionally implements
Sendon WASM.
Traits§
- Maybe
Send - Maybe
Send Future - Trait alias for
Future + MaybeSend. - Maybe
Sync
Functions§
- env_
mutation_ lock - Returns a process-wide mutex that serializes mutations of
std::envacross threads.
Type Aliases§
- BoxFuture
- Boxed future that is
Sendon native, unrestricted on WASM.