From 5bd6c78b5afc91c3caae6c56fc9f6b050df49806 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 16 Dec 2022 14:35:30 +0800 Subject: [PATCH] chore(napi): expose tokio runtime --- crates/napi/src/tokio_runtime.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/napi/src/tokio_runtime.rs b/crates/napi/src/tokio_runtime.rs index 7c7ac709..a3e49103 100644 --- a/crates/napi/src/tokio_runtime.rs +++ b/crates/napi/src/tokio_runtime.rs @@ -9,6 +9,10 @@ use crate::{check_status, sys, JsDeferred, JsUnknown, NapiValue, Result}; pub(crate) static RT: Lazy = Lazy::new(|| tokio::runtime::Runtime::new().expect("Create tokio runtime failed")); +pub fn runtime() -> &'static Runtime { + &RT +} + /// Spawns a future onto the Tokio runtime. /// /// Depending on where you use it, you should await or abort the future in your drop function.