mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
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.
This commit is contained in:
parent
a1b5a1bba3
commit
328407351c
1 changed files with 9 additions and 2 deletions
|
@ -137,6 +137,7 @@ impl Notifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! define_callback { ($($bounds: path),*) => {
|
||||||
/// A callback which is called when a [`Future`] completes.
|
/// A callback which is called when a [`Future`] completes.
|
||||||
///
|
///
|
||||||
/// Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
|
/// Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
|
||||||
|
@ -145,14 +146,20 @@ impl Notifier {
|
||||||
///
|
///
|
||||||
/// Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
|
/// Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
|
||||||
/// futures when they receive a wake, rather than immediately executing them.
|
/// futures when they receive a wake, rather than immediately executing them.
|
||||||
pub trait FutureCallback : Send {
|
pub trait FutureCallback : $($bounds +)* {
|
||||||
/// The method which is called.
|
/// The method which is called.
|
||||||
fn call(&self);
|
fn call(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: Fn() + Send> FutureCallback for F {
|
impl<F: Fn() $(+ $bounds)*> FutureCallback for F {
|
||||||
fn call(&self) { (self)(); }
|
fn call(&self) { (self)(); }
|
||||||
}
|
}
|
||||||
|
} }
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
define_callback!(Send);
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
define_callback!();
|
||||||
|
|
||||||
pub(crate) struct FutureState {
|
pub(crate) struct FutureState {
|
||||||
// When we're tracking whether a callback counts as having woken the user's code, we check the
|
// When we're tracking whether a callback counts as having woken the user's code, we check the
|
||||||
|
|
Loading…
Add table
Reference in a new issue