From a0652ee67322b727dfc8317ba6576924eac76b85 Mon Sep 17 00:00:00 2001 From: Pedro Fedricci Date: Tue, 9 Apr 2024 18:58:58 -0300 Subject: [PATCH] refactor(api)!: remove MutexNode reexports --- Makefile.toml | 6 ++++++ README.md | 2 +- examples/raw.rs | 2 +- examples/thread_local.rs | 4 ++-- src/lib.rs | 2 +- src/raw/mod.rs | 20 +++++--------------- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 1be57b4..3c9e9a6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -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" diff --git a/README.md b/README.md index b0460b2..19bb9b4 100644 --- a/README.md +++ b/README.md @@ -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)); diff --git a/examples/raw.rs b/examples/raw.rs index ed56e4c..754f511 100644 --- a/examples/raw.rs +++ b/examples/raw.rs @@ -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; diff --git a/examples/thread_local.rs b/examples/thread_local.rs index e991afb..5c8db73 100644 --- a/examples/thread_local.rs +++ b/examples/thread_local.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index 992ae40..d7ab907 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 6fdde21..f23e06a 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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();