@@ -12,7 +12,7 @@ use std::sync::Arc;
12
12
use std:: sync:: atomic:: { AtomicUsize , ATOMIC_USIZE_INIT , Ordering } ;
13
13
use std:: time:: { Instant , Duration } ;
14
14
15
- use futures:: { Future , IntoFuture , Async } ;
15
+ use futures:: { self , Future , IntoFuture , Async } ;
16
16
use futures:: task:: { self , Unpark , Task , Spawn } ;
17
17
use mio;
18
18
use slab:: Slab ;
@@ -576,6 +576,19 @@ impl Handle {
576
576
} ;
577
577
inner. borrow_mut ( ) . spawn ( Box :: new ( f) ) ;
578
578
}
579
+
580
+ /// Spawns a closure on this event loop.
581
+ ///
582
+ /// This function is a convenience wrapper around the `spawn` function above
583
+ /// for running a closure wrapped in `futures::lazy`. It will spawn the
584
+ /// function `f` provided onto the event loop, and continue to run the
585
+ /// future returned by `f` on the evnet loop as well.
586
+ pub fn spawn_fn < F , R > ( & self , f : F )
587
+ where F : FnOnce ( ) -> R + ' static ,
588
+ R : IntoFuture < Item =( ) , Error =( ) > + ' static ,
589
+ {
590
+ self . spawn ( futures:: lazy ( f) )
591
+ }
579
592
}
580
593
581
594
impl TimeoutState {
0 commit comments