nsr-nodejs 0.3.1

Node.js bindings for the NSR (Neuro-Symbolic Recursive) AI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Tokio runtime for async-to-sync bridging
//!
//! Node.js is single-threaded, so we use a shared tokio runtime
//! to execute async Rust code synchronously.

use std::sync::OnceLock;
use tokio::runtime::Runtime;

static RUNTIME: OnceLock<Runtime> = OnceLock::new();

/// Get the shared tokio runtime
pub fn get_runtime() -> &'static Runtime {
    RUNTIME.get_or_init(|| {
        Runtime::new().expect("Failed to create tokio runtime")
    })
}