@@ -409,60 +409,6 @@ pub fn block_on<T: 'static>(future: impl Future<Output = T> + 'static) -> T {
409409 }
410410}
411411
412- fn task_poll ( state : & mut FutureState ) -> bool {
413- #[ cfg( not( target_arch = "wasm32" ) ) ]
414- {
415- _ = state;
416- unreachable ! ( ) ;
417- }
418-
419- #[ cfg( target_arch = "wasm32" ) ]
420- {
421- #[ link( wasm_import_module = "$root" ) ]
422- extern "C" {
423- #[ link_name = "[task-poll]" ]
424- fn poll ( _: * mut i32 ) -> i32 ;
425- }
426- let mut payload = [ 0i32 ; 3 ] ;
427- unsafe {
428- let got_event = poll ( payload. as_mut_ptr ( ) ) != 0 ;
429- if got_event {
430- callback ( state as * mut _ as _ , payload[ 0 ] , payload[ 1 ] , payload[ 2 ] ) ;
431- }
432- got_event
433- }
434- }
435- }
436-
437- /// Attempt to run the specified future to completion without blocking,
438- /// returning the result if it completes.
439- ///
440- /// This is similar to `block_on` except that it uses `task.poll` instead of
441- /// `task.wait` to check for progress on any in-progress calls to async-lowered
442- /// imports, returning `None` if one or more of those calls remain pending.
443- // TODO: refactor so `'static` bounds aren't necessary
444- pub fn poll_future < T : ' static > ( future : impl Future < Output = T > + ' static ) -> Option < T > {
445- let ( tx, mut rx) = oneshot:: channel ( ) ;
446- let state = & mut FutureState {
447- todo : 0 ,
448- tasks : Some (
449- [ Box :: pin ( future. map ( move |v| drop ( tx. send ( v) ) ) ) as BoxFuture ]
450- . into_iter ( )
451- . collect ( ) ,
452- ) ,
453- } ;
454- loop {
455- match unsafe { poll ( state) } {
456- Poll :: Ready ( ( ) ) => break Some ( rx. try_recv ( ) . unwrap ( ) . unwrap ( ) ) ,
457- Poll :: Pending => {
458- if !task_poll ( state) {
459- break None ;
460- }
461- }
462- }
463- }
464- }
465-
466412/// Call the `task.yield` canonical built-in function.
467413///
468414/// This yields control to the host temporarily, allowing other tasks to make
0 commit comments