diff options
Diffstat (limited to 'src/transport/traffic.rs')
| -rw-r--r-- | src/transport/traffic.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs index b9506a9..948e5d5 100644 --- a/src/transport/traffic.rs +++ b/src/transport/traffic.rs @@ -158,6 +158,8 @@ const LOGGED_TEXT: usize = 8 * 1024; pub(crate) struct MessageLog { /// How many look (`watch`). watching: AtomicUsize, + /// Told of each message logged, for those sending them on as they come (`logged`). + logged: tokio::sync::Notify, inner: Mutex<LogInner>, } @@ -293,6 +295,18 @@ impl MessageLog { if inner.entries.len() > LOGGED { inner.entries.pop_front(); } + drop(inner); + self.logged.notify_waiters(); + } + + /// Until a message after `seq` is logged: at once if one is. Blocking nothing. + pub(crate) async fn logged_after(&self, seq: u64) { + // Made before looking, so a message logged in between still wakes it. + let logged = self.logged.notified(); + if self.latest() > seq { + return; + } + logged.await; } /// The messages after `seq`, the latest `most` of them. |
