File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed
Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ pub(crate) fn run() {
113113) ]
114114pub ( crate ) fn spawn < F > ( future : F )
115115where
116- F : Future < Output = ( ) > + Send + ' static ,
116+ F : Future < Output = ( ) > + ' static ,
117117{
118118 core_local:: ex ( ) . spawn ( AsyncTask :: new ( future) ) . detach ( ) ;
119119}
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ use wasi::*;
1010use wasmtime:: * ;
1111use zerocopy:: IntoBytes ;
1212
13- use crate :: console:: CONSOLE ;
1413use crate :: executor:: { WakerRegistration , spawn} ;
14+ use crate :: fd;
1515use crate :: kernel:: systemtime:: now_micros;
1616
1717mod capi;
@@ -271,15 +271,27 @@ pub extern "C" fn sys_unload_binary() -> i32 {
271271}
272272
273273async fn wasm_run ( ) {
274- future:: poll_fn ( |cx| {
275- let mut guard = OUTPUT . lock ( ) ;
276- while let Some ( data) = guard. data . pop_front ( ) {
277- CONSOLE . lock ( ) . write ( & data) ;
274+ loop {
275+ let obj = crate :: core_scheduler ( )
276+ . get_object ( fd:: STDOUT_FILENO )
277+ . await
278+ . unwrap ( ) ;
279+
280+ while let Some ( data) = OUTPUT . lock ( ) . data . pop_front ( ) {
281+ obj. write ( & data) . await . unwrap ( ) ;
278282 }
279- guard. waker . register ( cx. waker ( ) ) ;
280- Poll :: < ( ) > :: Pending
281- } )
282- . await ;
283+
284+ future:: poll_fn ( |cx| {
285+ let mut guard = OUTPUT . lock ( ) ;
286+ if guard. data . is_empty ( ) {
287+ guard. waker . register ( cx. waker ( ) ) ;
288+ Poll :: Pending
289+ } else {
290+ Poll :: Ready ( ( ) )
291+ }
292+ } )
293+ . await ;
294+ }
283295}
284296
285297#[ hermit_macro:: system]
You can’t perform that action at this time.
0 commit comments