ockam_node 0.118.0

This crate provides an implementation of an Ockam [Ockam][main-ockam-crate-link] Node and is intended for use by crates that provide features and add-ons to the main [Ockam][main-ockam-crate-link] library. The main [Ockam][main-ockam-crate-link] crate re-exports types defined in this crate, when the `"std"` feature is enabled.
Documentation
use once_cell::sync::Lazy;
use std::sync::Mutex;
use tokio::runtime::Runtime;

pub(crate) static RUNTIME: Lazy<Mutex<Option<Runtime>>> =
    Lazy::new(|| Mutex::new(Some(Runtime::new().unwrap())));

/// Return the Runtime singleton
/// This function can only be accessed once
pub fn take() -> Runtime {
    RUNTIME
        .lock()
        .unwrap()
        .take()
        .expect("Runtime was consumed")
}