File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,26 @@ impl<T> Event<T> {
205205 }
206206 }
207207
208+ /// Tell whether any listeners are currently notified.
209+ ///
210+ /// # Examples
211+ ///
212+ /// ```
213+ /// use event_listener::Event;
214+ ///
215+ /// let event = Event::new();
216+ /// let listener = event.listen();
217+ /// assert!(!event.is_notified());
218+ ///
219+ /// event.notify(1);
220+ /// assert!(event.is_notified());
221+ /// ```
222+ #[ inline]
223+ pub fn is_notified ( & self ) -> bool {
224+ self . try_inner ( )
225+ . map_or ( false , |inner| inner. notified . load ( Ordering :: Acquire ) > 0 )
226+ }
227+
208228 /// Returns a guard listening for a notification.
209229 ///
210230 /// This method emits a `SeqCst` fence after registering a listener. For now, this method
You can’t perform that action at this time.
0 commit comments