Skip to content

Commit

Permalink
refactor(api)!: remove MutexNode reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromfedricci committed Apr 9, 2024
1 parent 563e5f9 commit a0652ee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
6 changes: 6 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ command = "cargo"
env = { "RUSTFLAGS" = "${CLIPPY_FLAGS}" }
args = ["hack", "clippy", "--feature-powerset", "--no-dev-deps"]

# Run example.
[tasks.example]
command = "cargo"
env = { "RUSTFLAGS" = "${CLIPPY_FLAGS}" }
args = ["run", "--example", "${@}", "--all-features"]

# Lint all feature combinations with carg-hack on test profile.
[tasks.lint-test]
command = "cargo"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ more information.
use std::sync::Arc;
use std::thread;

use mcslock::raw::spins::{Mutex, MutexNode};
use mcslock::raw::{spins::Mutex, MutexNode};

fn main() {
let mutex = Arc::new(Mutex::new(0));
Expand Down
2 changes: 1 addition & 1 deletion examples/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread;

use mcslock::raw::spins::{Mutex, MutexNode};
use mcslock::raw::{spins::Mutex, MutexNode};

fn main() {
const N: usize = 10;
Expand Down
4 changes: 2 additions & 2 deletions examples/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ fn main() {
tx.send(()).unwrap();
}
// the lock is unlocked here when `data` goes out of scope.
})
});
});
}
let _message = rx.recv().unwrap();
let _message = rx.recv();

let count = data.lock_with_local(&NODE, |guard| *guard);
assert_eq!(count, N);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
//! use std::sync::Arc;
//! use std::thread;
//!
//! use mcslock::raw::spins::{Mutex, MutexNode};
//! use mcslock::raw::{spins::Mutex, MutexNode};
//!
//! let mutex = Arc::new(Mutex::new(0));
//! let c_mutex = Arc::clone(&mutex);
Expand Down
20 changes: 5 additions & 15 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ pub mod spins {
use super::mutex;
use crate::relax::Spin;

pub use mutex::MutexNode;

/// A `raw` MCS lock that implements the [`Spin`] relax strategy.
///
/// # Example
///
/// ```
/// use mcslock::raw::spins::{Mutex, MutexNode};
/// use mcslock::raw::{spins::Mutex, MutexNode};
///
/// let mutex = Mutex::new(0);
/// let mut node = MutexNode::new();
Expand All @@ -66,14 +64,12 @@ pub mod spins {
use super::mutex;
use crate::relax::SpinBackoff;

pub use mutex::MutexNode;

/// A `raw` MCS lock that implements the [`SpinBackoff`] relax strategy.
///
/// # Example
///
/// ```
/// use mcslock::raw::spins::backoff::{Mutex, MutexNode};
/// use mcslock::raw::{spins::backoff::Mutex, MutexNode};
///
/// let mutex = Mutex::new(0);
/// let mut node = MutexNode::new();
Expand All @@ -95,14 +91,12 @@ pub mod yields {
use super::mutex;
use crate::relax::Yield;

pub use mutex::MutexNode;

/// A `raw` MCS lock that implements the [`Yield`] relax strategy.
///
/// # Example
///
/// ```
/// use mcslock::raw::yields::{Mutex, MutexNode};
/// use mcslock::raw::{yields::Mutex, MutexNode};
///
/// let mutex = Mutex::new(0);
/// let mut node = MutexNode::new();
Expand All @@ -122,14 +116,12 @@ pub mod yields {
use super::mutex;
use crate::relax::YieldBackoff;

pub use mutex::MutexNode;

/// A `raw` MCS lock that implements the [`YieldBackoff`] relax strategy.
///
/// # Example
///
/// ```
/// use mcslock::raw::yields::backoff::{Mutex, MutexNode};
/// use mcslock::raw::{yields::backoff::Mutex, MutexNode};
///
/// let mutex = Mutex::new(0);
/// let mut node = MutexNode::new();
Expand All @@ -149,14 +141,12 @@ pub mod loops {
use super::mutex;
use crate::relax::Loop;

pub use mutex::MutexNode;

/// A `raw` MCS lock that implements the [`Loop`] relax strategy.
///
/// # Example
///
/// ```
/// use mcslock::raw::loops::{Mutex, MutexNode};
/// use mcslock::raw::{loops::Mutex, MutexNode};
///
/// let mutex = Mutex::new(0);
/// let mut node = MutexNode::new();
Expand Down

0 comments on commit a0652ee

Please sign in to comment.