chore(napi): expose tokio runtime

This commit is contained in:
LongYinan 2022-12-16 14:35:30 +08:00
parent c01bcecb2b
commit 5bd6c78b5a
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7

View file

@ -9,6 +9,10 @@ use crate::{check_status, sys, JsDeferred, JsUnknown, NapiValue, Result};
pub(crate) static RT: Lazy<Runtime> =
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.