mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 02:46:17 +04:00
gracefully handle lack of tokio runtime
This commit is contained in:
parent
7283ef881f
commit
386fa371d7
@ -28,7 +28,10 @@ fn spawn(self) -> mpsc::Sender<Self::Event> {
|
|||||||
// so it should only be reached in case of total CPU overload.
|
// so it should only be reached in case of total CPU overload.
|
||||||
// However, a bounded channel is much more efficient so it's nice to use here
|
// However, a bounded channel is much more efficient so it's nice to use here
|
||||||
let (tx, rx) = mpsc::channel(128);
|
let (tx, rx) = mpsc::channel(128);
|
||||||
|
// only spawn worker if we are inside runtime to avoid having to spawn a runtime for unrelated unit tests
|
||||||
|
if tokio::runtime::Handle::try_current().is_ok() {
|
||||||
tokio::spawn(run(self, rx));
|
tokio::spawn(run(self, rx));
|
||||||
|
}
|
||||||
tx
|
tx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user