Don't try launching a tokio runtime if we are already within one (#4699)
This commit is contained in:
1 parent
c709c415c9
commit
6456576a77
1 file changed
+17
-8
@@ -115,15 +115,24 @@ pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, mut desktop_config:
|
|||||||
pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) -> ! {
|
pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) -> ! {
|
||||||
#[cfg(feature = "tokio_runtime")]
|
#[cfg(feature = "tokio_runtime")]
|
||||||
{
|
{
|
||||||
tokio::runtime::Builder::new_multi_thread()
|
if let std::result::Result::Ok(handle) = tokio::runtime::Handle::try_current() {
|
||||||
.enable_all()
|
assert_ne!(
|
||||||
.build()
|
handle.runtime_flavor(),
|
||||||
.unwrap()
|
tokio::runtime::RuntimeFlavor::CurrentThread,
|
||||||
.block_on(tokio::task::unconstrained(async move {
|
"The tokio current-thread runtime does not work with dioxus event handling"
|
||||||
launch_virtual_dom_blocking(virtual_dom, desktop_config)
|
);
|
||||||
}));
|
launch_virtual_dom_blocking(virtual_dom, desktop_config);
|
||||||
|
} else {
|
||||||
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(tokio::task::unconstrained(async move {
|
||||||
|
launch_virtual_dom_blocking(virtual_dom, desktop_config)
|
||||||
|
}));
|
||||||
|
|
||||||
unreachable!("The desktop launch function will never exit")
|
unreachable!("The desktop launch function will never exit")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio_runtime"))]
|
#[cfg(not(feature = "tokio_runtime"))]
|
||||||
|
|||||||
Reference in new issue
Block a user