From: Matt Corallo Date: Fri, 26 Feb 2021 16:28:55 +0000 (-0500) Subject: Change ChannelManager::wait to be more descriptive X-Git-Tag: v0.0.13~6^2~7 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=578f8b72e2e5a04726fd1d5b63f9642bfc74a4b7;p=rust-lightning Change ChannelManager::wait to be more descriptive `wait` doesn't capture enough of what's going on, but also Java Java doesn't accpet methods just called `wait`, as it conflicts with existing sync primitives on all Objects. --- diff --git a/background-processor/src/lib.rs b/background-processor/src/lib.rs index 00f984580..1976962be 100644 --- a/background-processor/src/lib.rs +++ b/background-processor/src/lib.rs @@ -66,7 +66,7 @@ impl BackgroundProcessor { let handle = thread::spawn(move || -> Result<(), std::io::Error> { let mut current_time = Instant::now(); loop { - let updates_available = manager.wait_timeout(Duration::from_millis(100)); + let updates_available = manager.await_persistable_update_timeout(Duration::from_millis(100)); if updates_available { persist_manager(&*manager)?; } diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 8076e251b..536d6a74c 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -6072,7 +6072,7 @@ void ChannelManager_block_disconnected(const struct LDKChannelManager *NONNULL_P * Blocks until ChannelManager needs to be persisted. Only one listener on `wait` is * guaranteed to be woken up. */ -void ChannelManager_wait(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index a175a2ce9..a865372d0 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -784,8 +784,8 @@ pub extern "C" fn ChannelManager_block_disconnected(this_arg: &ChannelManager, h /// Blocks until ChannelManager needs to be persisted. Only one listener on `wait` is /// guaranteed to be woken up. #[no_mangle] -pub extern "C" fn ChannelManager_wait(this_arg: &ChannelManager) { - unsafe { &*this_arg.inner }.wait() +pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &ChannelManager) { + unsafe { &*this_arg.inner }.await_persistable_update() } impl From for crate::ln::msgs::ChannelMessageHandler { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 6e46d79fb..de0ce5359 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -480,10 +480,11 @@ pub struct ChainParameters { } /// Whenever we release the `ChannelManager`'s `total_consistency_lock`, from read mode, it is -/// desirable to notify any listeners on `wait_timeout`/`wait` that new updates are available for -/// persistence. Therefore, this struct is responsible for locking the total consistency lock and, -/// upon going out of scope, sending the aforementioned notification (since the lock being released -/// indicates that the updates are ready for persistence). +/// desirable to notify any listeners on `await_persistable_update_timeout`/ +/// `await_persistable_update` that new updates are available for persistence. Therefore, this +/// struct is responsible for locking the total consistency lock and, upon going out of scope, +/// sending the aforementioned notification (since the lock being released indicates that the +/// updates are ready for persistence). struct PersistenceNotifierGuard<'a> { persistence_notifier: &'a PersistenceNotifier, // We hold onto this result so the lock doesn't get released immediately. @@ -3407,17 +3408,19 @@ impl ChannelMana } /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool - /// indicating whether persistence is necessary. Only one listener on `wait_timeout` is - /// guaranteed to be woken up. + /// indicating whether persistence is necessary. Only one listener on + /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + /// up. /// Note that the feature `allow_wallclock_use` must be enabled to use this function. #[cfg(any(test, feature = "allow_wallclock_use"))] - pub fn wait_timeout(&self, max_wait: Duration) -> bool { + pub fn await_persistable_update_timeout(&self, max_wait: Duration) -> bool { self.persistence_notifier.wait_timeout(max_wait) } - /// Blocks until ChannelManager needs to be persisted. Only one listener on `wait` is - /// guaranteed to be woken up. - pub fn wait(&self) { + /// Blocks until ChannelManager needs to be persisted. Only one listener on + /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + /// up. + pub fn await_persistable_update(&self) { self.persistence_notifier.wait() } @@ -3669,7 +3672,7 @@ impl