@@ -6,7 +6,6 @@ use alloc::vec::Vec;
66use crate :: lsps0:: ser:: LSPSMessage ;
77use crate :: sync:: Mutex ;
88
9- use core:: sync:: atomic:: { AtomicBool , Ordering } ;
109use lightning:: util:: wakers:: { Future , Notifier } ;
1110
1211use bitcoin:: secp256k1:: PublicKey ;
@@ -17,33 +16,29 @@ use bitcoin::secp256k1::PublicKey;
1716pub struct MessageQueue {
1817 queue : Mutex < VecDeque < ( PublicKey , LSPSMessage ) > > ,
1918 pending_msgs_notifier : Notifier ,
20- needs_processing : AtomicBool ,
2119}
2220
2321impl MessageQueue {
2422 pub ( crate ) fn new ( ) -> Self {
2523 let queue = Mutex :: new ( VecDeque :: new ( ) ) ;
2624 let pending_msgs_notifier = Notifier :: new ( ) ;
27- let needs_processing = AtomicBool :: new ( false ) ;
28- Self { queue, pending_msgs_notifier, needs_processing }
25+ Self { queue, pending_msgs_notifier }
2926 }
3027
3128 pub ( crate ) fn get_and_clear_pending_msgs ( & self ) -> Vec < ( PublicKey , LSPSMessage ) > {
32- self . needs_processing . store ( false , Ordering :: Relaxed ) ;
3329 self . queue . lock ( ) . unwrap ( ) . drain ( ..) . collect ( )
3430 }
3531
3632 pub ( crate ) fn get_pending_msgs_future ( & self ) -> Future {
3733 self . pending_msgs_notifier . get_future ( )
3834 }
3935
40- // Returns a [`MessageQueueNotifierGuard`] that will call `process_msgs_callback` when dropped.
4136 pub ( crate ) fn notifier ( & self ) -> MessageQueueNotifierGuard {
4237 MessageQueueNotifierGuard { msg_queue : self , buffer : VecDeque :: new ( ) }
4338 }
4439}
4540
46- // A guard type that will notify about new messages when dropped.
41+ // A guard type that will process buffered messages and wake the background processor when dropped.
4742#[ must_use]
4843pub ( crate ) struct MessageQueueNotifierGuard < ' a > {
4944 msg_queue : & ' a MessageQueue ,
0 commit comments