X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fwakers.rs;fp=lightning%2Fsrc%2Futil%2Fwakers.rs;h=82e2dfc335ce95c2723cbba059a6c0d052bdd6a7;hb=328407351c6aeb84e9407281ec5d35b1a4690650;hp=1e41b2daee509697db87bd9e67c246b5c0cd25f2;hpb=a1b5a1bba38e0a4ab08603adbcf9e54f27e86f19;p=rust-lightning diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index 1e41b2da..82e2dfc3 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -137,6 +137,7 @@ impl Notifier { } } +macro_rules! define_callback { ($($bounds: path),*) => { /// 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 @@ -145,14 +146,20 @@ impl Notifier { /// /// 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. -pub trait FutureCallback : Send { +pub trait FutureCallback : $($bounds +)* { /// The method which is called. fn call(&self); } -impl FutureCallback for F { +impl FutureCallback for F { fn call(&self) { (self)(); } } +} } + +#[cfg(feature = "std")] +define_callback!(Send); +#[cfg(not(feature = "std"))] +define_callback!(); pub(crate) struct FutureState { // When we're tracking whether a callback counts as having woken the user's code, we check the