mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 21:26:50 +00:00
Optimize watcher range collection on notify.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
1 parent
7d8f7cbe5d
commit
fc0f04defa
1 file changed
+3
-2
@@ -8,11 +8,12 @@ use std::{
|
||||
use futures::pin_mut;
|
||||
use serde::Serialize;
|
||||
use tokio::sync::watch::{Sender, channel};
|
||||
use tuwunel_core::implement;
|
||||
use tuwunel_core::{implement, smallvec::SmallVec};
|
||||
|
||||
use crate::keyval::{KeyBuf, serialize_key};
|
||||
|
||||
type Watchers = Mutex<BTreeMap<KeyBuf, Sender<()>>>;
|
||||
type KeyVec = SmallVec<[KeyBuf; 1]>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct Watch {
|
||||
@@ -71,7 +72,7 @@ where
|
||||
.take_while(|(k, _)| key.as_ref().starts_with(k))
|
||||
.filter_map(|(k, tx)| tx.send(()).is_err().then_some(k))
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.collect::<KeyVec>()
|
||||
.into_iter()
|
||||
.for_each(|k| {
|
||||
watchers.remove(&k);
|
||||
|
||||
Reference in new issue
Block a user