Skip to content

Commit 2d171ae

Browse files
committed
Move the lock method to list.rs and rename it to try_lock
1 parent 1a4df18 commit 2d171ae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/lib.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct Inner {
165165
/// The number of notified entries, or `usize::MAX` if all of them have been notified.
166166
///
167167
/// If there are no entries, this value is set to `usize::MAX`.
168-
pub(crate) notified: AtomicUsize,
168+
notified: AtomicUsize,
169169

170170
/// Inner queue of event listeners.
171171
list: list::List,
@@ -179,14 +179,6 @@ impl Inner {
179179
list: list::List::new(),
180180
}
181181
}
182-
183-
/// Locks the list.
184-
pub(crate) fn lock(&self) -> Option<list::ListGuard<'_>> {
185-
self.list.inner.try_lock().map(|guard| list::ListGuard {
186-
inner: self,
187-
guard: Some(guard),
188-
})
189-
}
190182
}
191183

192184
/// A synchronization primitive for notifying async tasks and threads.

src/list.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ use core::ops;
1414
use slab::Slab;
1515

1616
impl crate::Inner {
17+
/// Locks the list.
18+
fn lock(&self) -> Option<ListGuard<'_>> {
19+
self.list.inner.try_lock().map(|guard| ListGuard {
20+
inner: self,
21+
guard: Some(guard),
22+
})
23+
}
24+
1725
/// Add a new listener to the list.
1826
///
1927
/// Does nothing if the list is already registered.

0 commit comments

Comments
 (0)