@@ -61,7 +61,7 @@ impl Builder {
6161 }
6262
6363 /// Spawns a task locally with the configured settings.
64- #[ cfg( not( target_os = "unknown" ) ) ]
64+ #[ cfg( all ( not( target_os = "unknown" ) , feature = "unstable ") ) ]
6565 pub fn local < F , T > ( self , future : F ) -> io:: Result < JoinHandle < T > >
6666 where
6767 F : Future < Output = T > + ' static ,
@@ -76,7 +76,7 @@ impl Builder {
7676 }
7777
7878 /// Spawns a task locally with the configured settings.
79- #[ cfg( target_arch = "wasm32" ) ]
79+ #[ cfg( all ( target_arch = "wasm32" , feature = "unstable" ) ) ]
8080 pub fn local < F , T > ( self , future : F ) -> io:: Result < JoinHandle < T > >
8181 where
8282 F : Future < Output = T > + ' static ,
@@ -96,6 +96,27 @@ impl Builder {
9696 Ok ( JoinHandle :: new ( receiver, task) )
9797 }
9898
99+ /// Spawns a task locally with the configured settings.
100+ #[ cfg( all( target_arch = "wasm32" , not( feature = "unstable" ) ) ) ]
101+ pub ( crate ) fn local < F , T > ( self , future : F ) -> io:: Result < JoinHandle < T > >
102+ where
103+ F : Future < Output = T > + ' static ,
104+ T : ' static ,
105+ {
106+ use futures_channel:: oneshot:: channel;
107+ let ( sender, receiver) = channel ( ) ;
108+
109+ let wrapped = self . build ( async move {
110+ let res = future. await ;
111+ let _ = sender. send ( res) ;
112+ } ) ;
113+
114+ let task = wrapped. tag . task ( ) . clone ( ) ;
115+ wasm_bindgen_futures:: spawn_local ( wrapped) ;
116+
117+ Ok ( JoinHandle :: new ( receiver, task) )
118+ }
119+
99120 /// Spawns a task with the configured settings, blocking on its execution.
100121 #[ cfg( not( target_os = "unknown" ) ) ]
101122 pub fn blocking < F , T > ( self , future : F ) -> T
0 commit comments