Skip to content

Commit

Permalink
scupt-net
Browse files Browse the repository at this point in the history
  • Loading branch information
ybbh committed Dec 11, 2023
1 parent ce4d547 commit 3ff970c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Notifier {
let inner = self.inner.clone();

let _r = task::spawn(async move {
inner.repeat_notify_until_no_waiting().await;
inner.task_repeat_notify_until_no_waiting().await;
});
ret
}
Expand All @@ -71,7 +71,9 @@ impl Notifier {
trace!("notify waiter {}", self.name);
let ret = self.inner.notify_all();
let inner = self.inner.clone();
inner.repeat_notify();
let _s = thread::Builder::new().spawn(move || {
inner.repeat_notify_until_no_waiting();
});
ret
}
}
Expand Down Expand Up @@ -119,14 +121,14 @@ impl NotifyInner {
}

// Keep invoking notify_waiters until the num_waiting is 0.
async fn repeat_notify_until_no_waiting(&self) {
async fn task_repeat_notify_until_no_waiting(&self) {
while self.num_waiting.load(SeqCst) != 0 {
sleep(Duration::from_millis(10)).await;
self.stop_notifier.notify_waiters();
}
}

fn repeat_notify(&self) {
fn repeat_notify_until_no_waiting(&self) {
while self.num_waiting.load(SeqCst) != 0 {
thread::sleep(Duration::from_millis(10));
self.stop_notifier.notify_waiters();
Expand Down

0 comments on commit 3ff970c

Please sign in to comment.