Skip to content

Commit

Permalink
Move impl from default to new
Browse files Browse the repository at this point in the history
* new has the description, so it should have the code.
  • Loading branch information
Lee-Janggun committed Mar 7, 2024
1 parent 10fcc09 commit 65a587f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/lockfree/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ unsafe impl<T: Send> Send for Queue<T> {}

impl<T> Default for Queue<T> {
fn default() -> Self {
Self::new()
}
}

impl<T> Queue<T> {
/// Create a new, empty queue.
pub fn new() -> Self {
let sentinel = Box::into_raw(Box::new(Node {
data: MaybeUninit::uninit(),
next: Atomic::null(),
Expand All @@ -50,13 +57,6 @@ impl<T> Default for Queue<T> {
tail: CachePadded::new(sentinel.into()),
}
}
}

impl<T> Queue<T> {
/// Create a new, empty queue.
pub fn new() -> Self {
Self::default()
}

/// Adds `t` to the back of the queue.
pub fn push(&self, t: T, guard: &mut Guard) {
Expand Down
8 changes: 4 additions & 4 deletions src/lockfree/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ unsafe impl<T: Send> Sync for Stack<T> {}

impl<T> Default for Stack<T> {
fn default() -> Self {
Self {
head: Atomic::null(),
}
Self::new()
}
}

impl<T> Stack<T> {
/// Creates a new, empty stack.
pub fn new() -> Stack<T> {
Self::default()
Self {
head: Atomic::null(),
}
}

/// Pushes a value on top of the stack.
Expand Down

0 comments on commit 65a587f

Please sign in to comment.