Skip to content

Commit e433505

Browse files
committed
feat(runtime): add Event::notified
1 parent 387f614 commit e433505

File tree

1 file changed

+11
-2
lines changed
  • compio-runtime/src/event

1 file changed

+11
-2
lines changed

compio-runtime/src/event/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ impl Flag {
2828
}))
2929
}
3030

31-
pub fn signal(&self) {
31+
pub fn notify(&self) {
3232
self.0.set.store(true, Ordering::Relaxed);
3333
self.0.waker.wake();
3434
}
35+
36+
pub fn notified(&self) -> bool {
37+
self.0.set.load(Ordering::Relaxed)
38+
}
3539
}
3640

3741
impl Future for Flag {
@@ -79,6 +83,11 @@ impl Event {
7983
EventHandle::new(self.flag.clone())
8084
}
8185

86+
/// Get if the event has been notified.
87+
pub fn notified(&self) -> bool {
88+
self.flag.notified()
89+
}
90+
8291
/// Wait for [`EventHandle::notify`] called.
8392
pub async fn wait(self) {
8493
self.flag.await
@@ -97,6 +106,6 @@ impl EventHandle {
97106

98107
/// Notify the event.
99108
pub fn notify(self) {
100-
self.flag.signal()
109+
self.flag.notify()
101110
}
102111
}

0 commit comments

Comments
 (0)