diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 1521982c062..ad0852b08d9 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -189,9 +189,9 @@ pub struct MultiThreadedLockableScore { } #[cfg(c_bindings)] /// A locked `MultiThreadedLockableScore`. -pub struct MultiThreadedLockableScoreLock<'a, S: Score>(MutexGuard<'a, S>); +pub struct MultiThreadedScoreLock<'a, S: Score>(MutexGuard<'a, S>); #[cfg(c_bindings)] -impl<'a, T: Score + 'a> Score for MultiThreadedLockableScoreLock<'a, T> { +impl<'a, T: Score + 'a> Score for MultiThreadedScoreLock<'a, T> { fn channel_penalty_msat(&self, scid: u64, source: &NodeId, target: &NodeId, usage: ChannelUsage) -> u64 { self.0.channel_penalty_msat(scid, source, target, usage) } @@ -209,7 +209,7 @@ impl<'a, T: Score + 'a> Score for MultiThreadedLockableScoreLock<'a, T> { } } #[cfg(c_bindings)] -impl<'a, T: Score + 'a> Writeable for MultiThreadedLockableScoreLock<'a, T> { +impl<'a, T: Score + 'a> Writeable for MultiThreadedScoreLock<'a, T> { fn write(&self, writer: &mut W) -> Result<(), io::Error> { self.0.write(writer) } @@ -217,10 +217,10 @@ impl<'a, T: Score + 'a> Writeable for MultiThreadedLockableScoreLock<'a, T> { #[cfg(c_bindings)] impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore { - type Locked = MultiThreadedLockableScoreLock<'a, T>; + type Locked = MultiThreadedScoreLock<'a, T>; - fn lock(&'a self) -> MultiThreadedLockableScoreLock<'a, T> { - MultiThreadedLockableScoreLock(Mutex::lock(&self.score).unwrap()) + fn lock(&'a self) -> MultiThreadedScoreLock<'a, T> { + MultiThreadedScoreLock(Mutex::lock(&self.score).unwrap()) } } diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index e49c832ef67..166771948fa 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -163,6 +163,8 @@ pub struct Future { impl Future { /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. + /// + /// (C-not exported) use the bindings-only `register_callback_fn` instead pub fn register_callback(&self, callback: Box) { let mut state = self.state.lock().unwrap(); if state.complete { @@ -172,6 +174,16 @@ impl Future { state.callbacks.push(callback); } } + + // C bindings don't (currently) know how to map `Box`, and while it could add the + // following wrapper, doing it in the bindings is currently much more work than simply doing it + // here. + /// Registers a callback to be called upon completion of this future. If the future has already + /// completed, the callback will be called immediately. + #[cfg(c_bindings)] + pub fn register_callback_fn(&self, callback: F) { + self.register_callback(Box::new(callback)); + } } mod std_future {