freya-core 0.5.0

Reactivity runtime, tree management, accessibility integration, rendering pipeline and more, for Freya
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::future::Future;

/// Runs a blocking closure off the caller's thread.
#[cfg(not(target_os = "emscripten"))]
pub fn thread<T: Send + 'static>(
    function: impl FnOnce() -> T + Send + 'static,
) -> impl Future<Output = T> {
    blocking::unblock(function)
}

/// Runs a blocking closure inline.
#[cfg(target_os = "emscripten")]
pub fn thread<T: Send + 'static>(
    function: impl FnOnce() -> T + Send + 'static,
) -> impl Future<Output = T> {
    std::future::ready(function())
}