File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ pub struct EventFuture {
4343 event : Event ,
4444 shared : SharedWaker ,
4545 set_callback : bool ,
46- queue : Queue ,
46+ queue : Option < Queue > ,
4747}
4848
4949impl Future for EventFuture {
@@ -55,8 +55,10 @@ impl Future for EventFuture {
5555 // Set the callback on first Future poll (Futures can't be active until polled)
5656 if * this. set_callback == false {
5757 * this. set_callback = true ;
58+ let mut queue = Queue :: new_immediate ( ) ;
5859 this. shared . waker . register ( cx. waker ( ) ) ;
59- unsafe { ffi:: register_callback ( & mut this. queue . 0 , & this. event . 0 , this. shared ) } ;
60+ unsafe { ffi:: register_callback ( & mut queue. 0 , & this. event . 0 , this. shared ) } ;
61+ this. queue . replace ( queue) ;
6062
6163 // Check the event again to avoid a race condition
6264 // https://docs.rs/futures/latest/futures/task/struct.AtomicWaker.html#examples
@@ -98,7 +100,7 @@ impl IntoFuture for Event {
98100 event : self ,
99101 shared : SharedWaker :: new ( ) ,
100102 set_callback : false ,
101- queue : Queue :: new_immediate ( ) ,
103+ queue : None ,
102104 }
103105 }
104106}
You can’t perform that action at this time.
0 commit comments