Skip to content

Commit 393566a

Browse files
committed
Move node.rs and queue.rs to be submodules of list.rs
This move abstracts them to be a sub-module of the inner list.
1 parent 2d171ae commit 393566a

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ extern crate alloc;
6969
extern crate std;
7070

7171
mod list;
72-
mod node;
73-
mod queue;
7472
mod sync;
7573

7674
use alloc::sync::Arc;

src/list.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
//! The inner list of listeners.
22
3-
use crate::node::{Node, TaskWaiting};
4-
use crate::queue::Queue;
3+
#[path = "list/node.rs"]
4+
mod node;
5+
6+
#[path = "list/queue.rs"]
7+
mod queue;
8+
9+
use node::{Node, TaskWaiting};
10+
use queue::Queue;
11+
512
use crate::sync::atomic::{AtomicBool, Ordering};
613
use crate::sync::cell::{Cell, UnsafeCell};
714
use crate::sync::Arc;
@@ -15,7 +22,7 @@ use slab::Slab;
1522

1623
impl crate::Inner {
1724
/// Locks the list.
18-
fn lock(&self) -> Option<ListGuard<'_>> {
25+
fn try_lock(&self) -> Option<ListGuard<'_>> {
1926
self.list.inner.try_lock().map(|guard| ListGuard {
2027
inner: self,
2128
guard: Some(guard),
@@ -31,7 +38,7 @@ impl crate::Inner {
3138
return;
3239
}
3340

34-
match self.lock() {
41+
match self.try_lock() {
3542
Some(mut lock) => {
3643
let key = lock.insert(State::Created);
3744
*listener = Listener::HasNode(key);
@@ -50,7 +57,7 @@ impl crate::Inner {
5057
pub(crate) fn remove(&self, listener: &mut Listener, propogate: bool) -> Option<State> {
5158
let state = match mem::replace(listener, Listener::Discarded) {
5259
Listener::HasNode(key) => {
53-
match self.lock() {
60+
match self.try_lock() {
5461
Some(mut list) => {
5562
// Fast path removal.
5663
list.remove(Listener::HasNode(key), propogate)
@@ -85,7 +92,7 @@ impl crate::Inner {
8592
/// Notifies a number of entries.
8693
#[cold]
8794
pub(crate) fn notify(&self, n: usize, additional: bool) {
88-
match self.lock() {
95+
match self.try_lock() {
8996
Some(mut guard) => {
9097
// Notify the listeners.
9198
guard.notify(n, additional);
@@ -112,7 +119,7 @@ impl crate::Inner {
112119
match mem::replace(listener, Listener::Discarded) {
113120
Listener::HasNode(key) => {
114121
*listener = Listener::HasNode(key);
115-
match self.lock() {
122+
match self.try_lock() {
116123
Some(mut guard) => {
117124
// Fast path registration.
118125
return guard.register(listener, task);
File renamed without changes.

src/queue.rs renamed to src/list/queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The queue of nodes that keeps track of pending operations.
22
3-
use crate::node::Node;
3+
use super::node::Node;
44
use crate::sync::atomic::{AtomicPtr, Ordering};
55

66
use crossbeam_utils::CachePadded;

0 commit comments

Comments
 (0)