Skip to content

Commit 3284073

Browse files
committed
Do not bound callbacks by Send when building for no-std
`Send` is rather useless on a `no-std` target - we don't have threads and are just needlessly restricting ourselves, so here we skip it for the wakers callback.
1 parent a1b5a1b commit 3284073

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lightning/src/util/wakers.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl Notifier {
137137
}
138138
}
139139

140+
macro_rules! define_callback { ($($bounds: path),*) => {
140141
/// A callback which is called when a [`Future`] completes.
141142
///
142143
/// Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
@@ -145,14 +146,20 @@ impl Notifier {
145146
///
146147
/// Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
147148
/// futures when they receive a wake, rather than immediately executing them.
148-
pub trait FutureCallback : Send {
149+
pub trait FutureCallback : $($bounds +)* {
149150
/// The method which is called.
150151
fn call(&self);
151152
}
152153

153-
impl<F: Fn() + Send> FutureCallback for F {
154+
impl<F: Fn() $(+ $bounds)*> FutureCallback for F {
154155
fn call(&self) { (self)(); }
155156
}
157+
} }
158+
159+
#[cfg(feature = "std")]
160+
define_callback!(Send);
161+
#[cfg(not(feature = "std"))]
162+
define_callback!();
156163

157164
pub(crate) struct FutureState {
158165
// When we're tracking whether a callback counts as having woken the user's code, we check the

0 commit comments

Comments
 (0)