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

Function asyncify

crates/engine/src/util.rs:7–21  ·  view source on GitHub ↗

Ergonomic wrapper for `runtime.spawn_blocking(f).await`. If `f` panics, it will be bubbled up to the calling task.

(runtime: &Handle, f: F)

Source from the content-addressed store, hash-verified

5///
6/// If `f` panics, it will be bubbled up to the calling task.
7pub async fn asyncify<F, R>(runtime: &Handle, f: F) -> R
8where
9 F: FnOnce() -> R + Send + 'static,
10 R: Send + 'static,
11{
12 // Ensure that `f` executes in the current span context.
13 // If there is no current span, or it is disabled, `span` is disabled.
14 let span = Span::current();
15 runtime
16 .spawn_blocking(move || {
17 let _enter = span.enter();
18 f()
19 })
20 .await
21}

Callers 4

local_historyFunction · 0.70
persistenceMethod · 0.70

Calls 1

spawn_blockingMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…