X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fwakers.rs;h=166771948fad62bc2f10078b5360fb67207f50f5;hb=d9f5c407de73cc58d6ae13ac3951083671fa1f2f;hp=e49c832ef67fd8aeb0dd25f193eb3fe179bb57c1;hpb=15a5966fa24286ca805aea3a97e606b10c71543d;p=rust-lightning diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index e49c832e..16677194 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 {