@@ -95,7 +95,7 @@ impl LoopHandle {
95
95
/// closure `f`, generate a handle, and then the future will yield it back.
96
96
// TODO: more with examples
97
97
pub fn add_loop_data < F , A > ( & self , f : F ) -> AddLoopData < F , A >
98
- where F : FnOnce ( ) -> A + Send + ' static ,
98
+ where F : FnOnce ( & LoopPin ) -> A + Send + ' static ,
99
99
A : ' static ,
100
100
{
101
101
AddLoopData {
@@ -109,18 +109,19 @@ impl LoopHandle {
109
109
}
110
110
111
111
impl < F , A > Future for AddLoopData < F , A >
112
- where F : FnOnce ( ) -> A + Send + ' static ,
112
+ where F : FnOnce ( & LoopPin ) -> A + Send + ' static ,
113
113
A : ' static ,
114
114
{
115
115
type Item = LoopData < A > ;
116
116
type Error = io:: Error ;
117
117
118
118
fn poll ( & mut self ) -> Poll < LoopData < A > , io:: Error > {
119
- let ret = self . inner . poll ( |_lp , f| {
120
- Ok ( DropBox :: new ( f ( ) ) )
119
+ let ret = self . inner . poll ( |lp , f| {
120
+ Ok ( DropBox :: new ( f ( & lp . pin ( ) ) ) )
121
121
} , |f, slot| {
122
122
Message :: Run ( Box :: new ( move || {
123
- slot. try_produce ( Ok ( DropBox :: new ( f ( ) ) ) ) . ok ( )
123
+ let pin = super :: CURRENT_LOOP . with ( |lp| lp. pin ( ) ) ;
124
+ slot. try_produce ( Ok ( DropBox :: new ( f ( & pin) ) ) ) . ok ( )
124
125
. expect ( "add loop data try_produce intereference" ) ;
125
126
} ) )
126
127
} ) ;
0 commit comments