runtime: remove IN_TOKIO thread local variable
tokio now has Handle::try_current() allowing us to generally check for a tokio runtime even if spawned by someone else Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3243f93ce7
commit
1283d58ca9
@ -11,11 +11,11 @@ use tokio::runtime::{self, Runtime};
|
|||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static HAS_RUNTIME: RefCell<bool> = RefCell::new(false);
|
static HAS_RUNTIME: RefCell<bool> = RefCell::new(false);
|
||||||
static IN_TOKIO: RefCell<bool> = RefCell::new(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_in_tokio() -> bool {
|
fn is_in_tokio() -> bool {
|
||||||
IN_TOKIO.with(|v| *v.borrow())
|
tokio::runtime::Handle::try_current()
|
||||||
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_runtime() -> bool {
|
fn has_runtime() -> bool {
|
||||||
@ -47,7 +47,6 @@ lazy_static! {
|
|||||||
runtime::Builder::new()
|
runtime::Builder::new()
|
||||||
.threaded_scheduler()
|
.threaded_scheduler()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.on_thread_start(|| IN_TOKIO.with(|v| *v.borrow_mut() = true))
|
|
||||||
.build()
|
.build()
|
||||||
.expect("failed to spawn tokio runtime")
|
.expect("failed to spawn tokio runtime")
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user