Skip to content

Commit db42ad6

Browse files
authored
Merge pull request #4535 from TheBlueMatt/2026-04-reentrant-futures
Document that `Future` callbacks are not reentrant-safe
2 parents 4f5e64a + b06ba3f commit db42ad6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lightning/src/util/wakers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ impl Future {
165165
/// Registers a callback to be called upon completion of this future. If the future has already
166166
/// completed, the callback will be called immediately.
167167
///
168+
/// Note that callbacks *must not* reenter this [`Future`] or the corresponding [`Notifier`].
169+
///
168170
/// This is not exported to bindings users, use the bindings-only `register_callback_fn` instead
169171
pub fn register_callback(&self, callback: Box<dyn FutureCallback>) {
170172
let mut state = self.state.lock().unwrap();
@@ -182,6 +184,8 @@ impl Future {
182184
// here.
183185
/// Registers a callback to be called upon completion of this future. If the future has already
184186
/// completed, the callback will be called immediately.
187+
///
188+
/// Note that callbacks *must not* reenter this [`Future`] or the corresponding [`Notifier`].
185189
#[cfg(c_bindings)]
186190
pub fn register_callback_fn<F: 'static + FutureCallback>(&self, callback: F) {
187191
self.register_callback(Box::new(callback));

0 commit comments

Comments
 (0)