@@ -30,17 +30,29 @@ use core::pin::Pin;
30
30
use core:: task:: { Context , Poll } ;
31
31
32
32
/// Used to signal to one of many waiters that the condition they're waiting on has happened.
33
- pub ( crate ) struct Notifier {
33
+ ///
34
+ /// This is usually used by LDK objects such as [`ChannelManager`] or [`PeerManager`] to signal to
35
+ /// the background processor that it should wake up and process pending events.
36
+ ///
37
+ /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
38
+ /// [`PeerManager`]: crate::ln::peer_handler::PeerManager
39
+ pub struct Notifier {
34
40
notify_pending : Mutex < ( bool , Option < Arc < Mutex < FutureState > > > ) > ,
35
41
}
36
42
37
43
impl Notifier {
38
- pub ( crate ) fn new ( ) -> Self {
44
+ /// Constructs a new notifier.
45
+ pub fn new ( ) -> Self {
39
46
Self { notify_pending : Mutex :: new ( ( false , None ) ) }
40
47
}
41
48
42
49
/// Wake waiters, tracking that wake needs to occur even if there are currently no waiters.
43
- pub ( crate ) fn notify ( & self ) {
50
+ ///
51
+ /// We deem the notification successful either directly after any callbacks were made, or after
52
+ /// the user [`poll`]ed a previously-completed future.
53
+ ///
54
+ /// [`poll`]: core::future::Future::poll
55
+ pub fn notify ( & self ) {
44
56
let mut lock = self . notify_pending . lock ( ) . unwrap ( ) ;
45
57
if let Some ( future_state) = & lock. 1 {
46
58
if complete_future ( future_state) {
@@ -52,7 +64,7 @@ impl Notifier {
52
64
}
53
65
54
66
/// Gets a [`Future`] that will get woken up with any waiters
55
- pub ( crate ) fn get_future ( & self ) -> Future {
67
+ pub fn get_future ( & self ) -> Future {
56
68
let mut lock = self . notify_pending . lock ( ) . unwrap ( ) ;
57
69
let mut self_idx = 0 ;
58
70
if let Some ( existing_state) = & lock. 1 {
0 commit comments