File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -115,15 +115,20 @@ pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, mut desktop_config:
115
115
pub fn launch_virtual_dom ( virtual_dom : VirtualDom , desktop_config : Config ) -> ! {
116
116
#[ cfg( feature = "tokio_runtime" ) ]
117
117
{
118
- tokio:: runtime:: Builder :: new_multi_thread ( )
119
- . enable_all ( )
120
- . build ( )
121
- . unwrap ( )
122
- . block_on ( tokio:: task:: unconstrained ( async move {
123
- launch_virtual_dom_blocking ( virtual_dom, desktop_config)
124
- } ) ) ;
125
-
126
- unreachable ! ( "The desktop launch function will never exit" )
118
+ if let std:: result:: Result :: Ok ( handle) = tokio:: runtime:: Handle :: try_current ( ) {
119
+ assert_ne ! ( handle. runtime_flavor( ) , tokio:: runtime:: RuntimeFlavor :: CurrentThread , "Current thread runtime does not allow event handling" ) ;
120
+ launch_virtual_dom_blocking ( virtual_dom, desktop_config) ;
121
+ } else {
122
+ tokio:: runtime:: Builder :: new_multi_thread ( )
123
+ . enable_all ( )
124
+ . build ( )
125
+ . unwrap ( )
126
+ . block_on ( tokio:: task:: unconstrained ( async move {
127
+ launch_virtual_dom_blocking ( virtual_dom, desktop_config)
128
+ } ) ) ;
129
+
130
+ unreachable ! ( "The desktop launch function will never exit" )
131
+ }
127
132
}
128
133
129
134
#[ cfg( not( feature = "tokio_runtime" ) ) ]
You can’t perform that action at this time.
0 commit comments