Skip to content

Commit 15b4ea2

Browse files
committed
Seal the Notification and IntoNotification traits
This PR seals these two traits to prevent breaking changes from causing semver breaks. It also adds documentation to both traits.
1 parent 723c328 commit 15b4ea2

File tree

5 files changed

+288
-72
lines changed

5 files changed

+288
-72
lines changed

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ use std::time::{Duration, Instant};
9797
use sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
9898
use sync::{Arc, WithMut};
9999

100-
pub use notify::{Additional, IntoNotification, Notification, Notify, Tag, TagWith};
100+
use notify::{Internal, NotificationPrivate};
101+
pub use notify::{IntoNotification, Notification};
101102

102103
/// Useful traits for notifications.
103104
pub mod prelude {
@@ -343,13 +344,13 @@ impl<T> Event<T> {
343344
let notify = notify.into_notification();
344345

345346
// Make sure the notification comes after whatever triggered it.
346-
notify.fence();
347+
notify.fence(notify::Internal::new());
347348

348349
if let Some(inner) = self.try_inner() {
349-
let limit = if notify.is_additional() {
350+
let limit = if notify.is_additional(Internal::new()) {
350351
core::usize::MAX
351352
} else {
352-
notify.count()
353+
notify.count(Internal::new())
353354
};
354355

355356
// Notify if there is at least one unnotified listener and the number of notified

src/no_std.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod queue;
1818
use node::{Node, TaskWaiting};
1919
use queue::Queue;
2020

21-
use crate::notify::{GenericNotify, Notification};
21+
use crate::notify::{GenericNotify, Internal, Notification};
2222
use crate::sync::atomic::{AtomicBool, Ordering};
2323
use crate::sync::cell::{Cell, UnsafeCell};
2424
use crate::sync::Arc;
@@ -121,15 +121,15 @@ impl<T> crate::Inner<T> {
121121
None => {
122122
// Push it to the queue.
123123
let node = Node::Notify(GenericNotify::new(
124-
notify.count(),
125-
notify.is_additional(),
124+
notify.count(Internal::new()),
125+
notify.is_additional(Internal::new()),
126126
{
127127
// Collect every tag we need.
128128
let mut tags = {
129-
let count = notify.count();
129+
let count = notify.count(Internal::new());
130130
let mut tags = Vec::with_capacity(count);
131131
for _ in 0..count {
132-
tags.push(notify.next_tag());
132+
tags.push(notify.next_tag(Internal::new()));
133133
}
134134

135135
// Convert into an iterator.
@@ -571,8 +571,8 @@ impl<T> ListenerSlab<T> {
571571
/// Notifies a number of listeners.
572572
#[cold]
573573
pub(crate) fn notify(&mut self, mut notify: impl Notification<Tag = T>) {
574-
let mut n = notify.count();
575-
let is_additional = notify.is_additional();
574+
let mut n = notify.count(Internal::new());
575+
let is_additional = notify.is_additional(Internal::new());
576576
if !is_additional {
577577
// Make sure we're not notifying more than we have.
578578
if n <= self.notified {
@@ -594,7 +594,7 @@ impl<T> ListenerSlab<T> {
594594
self.start = entry.next().get();
595595

596596
// Set the state to `Notified` and notify.
597-
let tag = notify.next_tag();
597+
let tag = notify.next_tag(Internal::new());
598598
if let State::Task(task) = entry.state().replace(State::Notified {
599599
tag,
600600
additional: is_additional,

src/no_std/queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<T> Drop for Queue<T> {
129129

130130
#[cfg(test)]
131131
mod tests {
132-
use crate::notify::{GenericNotify, Notification};
132+
use crate::notify::{GenericNotify, Internal, NotificationPrivate};
133133

134134
use super::*;
135135

@@ -139,7 +139,7 @@ mod tests {
139139

140140
fn node_to_num(node: Node<()>) -> usize {
141141
match node {
142-
Node::Notify(notify) => notify.count(),
142+
Node::Notify(notify) => notify.count(Internal::new()),
143143
_ => panic!("unexpected node"),
144144
}
145145
}

0 commit comments

Comments
 (0)