kithara-platform 0.0.1-alpha4

Cross-platform primitives (sync, time, thread) for native and wasm32.
Documentation
pub use super::backend::task::*;
use super::runtime::Handle;

/// Spawn `future` on a specific runtime [`Handle`]: a direct `handle.spawn`.
///
/// The native backend has no orchestration around task polls, so spawning
/// onto a specific runtime [`Handle`] needs no wrapping.
pub fn spawn_on<F>(handle: &Handle, future: F) -> JoinHandle<F::Output>
where
    F: Future + Send + 'static,
    F::Output: Send + 'static,
{
    handle.spawn(future)
}

/// Spawn a blocking computation on the runtime's blocking pool.
pub fn spawn_blocking<F, R>(f: F) -> JoinHandle<R>
where
    F: FnOnce() -> R + Send + 'static,
    R: Send + 'static,
{
    super::backend::task::spawn_blocking(f)
}

/// Spawn a blocking computation on a specific runtime [`Handle`].
pub fn spawn_blocking_on<F, R>(handle: &Handle, f: F) -> JoinHandle<R>
where
    F: FnOnce() -> R + Send + 'static,
    R: Send + 'static,
{
    handle.spawn_blocking(f)
}