1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Hook trait for the optional async runtime (`cljrs-async`).
//!
//! Core crates never import Tokio. When `cljrs-async` is linked, it calls
//! `GlobalEnv::set_async_runtime` to install itself. The evaluator then
//! delegates `^:async` fn dispatch through this trait.
use Value;
use crateEnv;
use crateEvalResult;
/// Interface implemented by `cljrs-async` and registered with `GlobalEnv`.
///
/// All methods are called from the LocalSet thread, so `Value` / `Env` need
/// not be `Send`. The trait itself must be `Send + Sync` so the
/// `Arc<dyn AsyncRuntime>` inside `GlobalEnv` can be shared.
// ── Async JIT compile hook ──────────────────────────────────────────────────
//
// `cljrs-async` drives `^:async` dispatch but cannot compile (it sits below
// `cljrs-jit`). `cljrs-jit::init` installs this hook; the async dispatcher
// invokes it (once per arity) to lower + compile + register a native poll
// function for the called `^:async` arity. A no-op when the JIT is absent, so
// dispatch keeps tree-walking via `eval_async`.
/// Signature of the async-JIT compile hook: `(callee_fn, nargs, env)`.
pub type AsyncCompileHook = fn;
static ASYNC_COMPILE_HOOK: OnceLock = new;
/// Install the async-JIT compile hook (called once by `cljrs-jit::init`).
/// The installed async-JIT compile hook, if any.