Skip to content

Commit b43466f

Browse files
committed
f another bool drop and update comment
1 parent a194534 commit b43466f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lightning/src/util/wakers.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ define_callback!(Send);
110110
define_callback!();
111111

112112
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).
116117
callbacks: Vec<Box<dyn FutureCallback>>,
117118
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>>,
119120
complete: bool,
120121
callbacks_made: bool,
121122
}
@@ -130,9 +131,8 @@ fn complete_future(this: &Arc<Mutex<FutureState>>) -> bool {
130131
for waker in state.std_future_callbacks.drain(..) {
131132
waker.0.wake_by_ref();
132133
}
133-
for (counts_as_call, callback) in state.callbacks_with_state.drain(..) {
134+
for callback in state.callbacks_with_state.drain(..) {
134135
(callback)(this);
135-
state.callbacks_made |= counts_as_call;
136136
}
137137
state.complete = true;
138138
state.callbacks_made
@@ -253,10 +253,10 @@ impl Sleeper {
253253
*notified_fut_mtx.lock().unwrap() = Some(Arc::clone(&notifier_mtx));
254254
break;
255255
}
256-
notifier.callbacks_with_state.push((false, Box::new(move |notifier_ref| {
256+
notifier.callbacks_with_state.push(Box::new(move |notifier_ref| {
257257
*notified_fut_ref.lock().unwrap() = Some(Arc::clone(notifier_ref));
258258
cv_ref.notify_all();
259-
})));
259+
}));
260260
}
261261
}
262262
(cv, notified_fut_mtx)

0 commit comments

Comments
 (0)