@@ -110,12 +110,13 @@ define_callback!(Send);
110
110
define_callback ! ( ) ;
111
111
112
112
pub ( crate ) struct FutureState {
113
- // When we're tracking whether a callback counts as having woken the user's code, we check the
114
- // first bool - set to false if we're just calling a Waker, and true if we're calling an actual
115
- // user-provided function.
113
+ // `callbacks` count as having woken the users' code (as they go direct to the user), but
114
+ // `std_future_callbacks` and `callbacks_with_state` do not (as the first just wakes a future,
115
+ // we only count it after another `poll()` and the second wakes a `Sleeper` which handles
116
+ // setting `callbacks_made` itself).
116
117
callbacks : Vec < Box < dyn FutureCallback > > ,
117
118
std_future_callbacks : Vec < StdWaker > ,
118
- callbacks_with_state : Vec < ( bool , Box < dyn Fn ( & Arc < Mutex < FutureState > > ) -> ( ) + Send > ) > ,
119
+ callbacks_with_state : Vec < Box < dyn Fn ( & Arc < Mutex < FutureState > > ) -> ( ) + Send > > ,
119
120
complete : bool ,
120
121
callbacks_made : bool ,
121
122
}
@@ -130,9 +131,8 @@ fn complete_future(this: &Arc<Mutex<FutureState>>) -> bool {
130
131
for waker in state. std_future_callbacks . drain ( ..) {
131
132
waker. 0 . wake_by_ref ( ) ;
132
133
}
133
- for ( counts_as_call , callback) in state. callbacks_with_state . drain ( ..) {
134
+ for callback in state. callbacks_with_state . drain ( ..) {
134
135
( callback) ( this) ;
135
- state. callbacks_made |= counts_as_call;
136
136
}
137
137
state. complete = true ;
138
138
state. callbacks_made
@@ -253,10 +253,10 @@ impl Sleeper {
253
253
* notified_fut_mtx. lock ( ) . unwrap ( ) = Some ( Arc :: clone ( & notifier_mtx) ) ;
254
254
break ;
255
255
}
256
- notifier. callbacks_with_state . push ( ( false , Box :: new ( move |notifier_ref| {
256
+ notifier. callbacks_with_state . push ( Box :: new ( move |notifier_ref| {
257
257
* notified_fut_ref. lock ( ) . unwrap ( ) = Some ( Arc :: clone ( notifier_ref) ) ;
258
258
cv_ref. notify_all ( ) ;
259
- } ) ) ) ;
259
+ } ) ) ;
260
260
}
261
261
}
262
262
( cv, notified_fut_mtx)
0 commit comments