MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / run_blocking

Function run_blocking

crates/cli/src/tasks/javascript.rs:33–42  ·  view source on GitHub ↗

Synchronously run an async future from a non-async function. - If we're already inside a Tokio runtime, we switch to the blocking pool and `block_on` the future (prevents scheduler starvation). - Otherwise, we use a shared, long-lived runtime.

(fut: F)

Source from the content-addressed store, hash-verified

31/// and `block_on` the future (prevents scheduler starvation).
32/// - Otherwise, we use a shared, long-lived runtime.
33pub fn run_blocking<F, T>(fut: F) -> T
34where
35 F: std::future::Future<Output = T> + Send + 'static,
36 T: Send + 'static,
37{
38 match Handle::try_current() {
39 Ok(handle) => tokio::task::block_in_place(|| handle.block_on(fut)),
40 Err(_) => runtime().block_on(fut),
41 }
42}
43
44pub(crate) fn build_javascript(project_path: &Path, build_debug: bool) -> anyhow::Result<PathBuf> {
45 let cwd = fs::canonicalize(project_path)?;

Callers 1

build_javascriptFunction · 0.85

Calls 2

runtimeFunction · 0.85
block_onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…