From 65a587fbac56323160eee28ff41e27a86634b9fb Mon Sep 17 00:00:00 2001 From: Janggun Lee Date: Thu, 7 Mar 2024 14:53:14 +0900 Subject: [PATCH] Move impl from default to new * new has the description, so it should have the code. --- src/lockfree/queue.rs | 14 +++++++------- src/lockfree/stack.rs | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lockfree/queue.rs b/src/lockfree/queue.rs index a09405083d..a4ace84caa 100644 --- a/src/lockfree/queue.rs +++ b/src/lockfree/queue.rs @@ -39,6 +39,13 @@ unsafe impl Send for Queue {} impl Default for Queue { fn default() -> Self { + Self::new() + } +} + +impl Queue { + /// Create a new, empty queue. + pub fn new() -> Self { let sentinel = Box::into_raw(Box::new(Node { data: MaybeUninit::uninit(), next: Atomic::null(), @@ -50,13 +57,6 @@ impl Default for Queue { tail: CachePadded::new(sentinel.into()), } } -} - -impl Queue { - /// 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) { diff --git a/src/lockfree/stack.rs b/src/lockfree/stack.rs index 371389c9ee..92912e2794 100644 --- a/src/lockfree/stack.rs +++ b/src/lockfree/stack.rs @@ -24,16 +24,16 @@ unsafe impl Sync for Stack {} impl Default for Stack { fn default() -> Self { - Self { - head: Atomic::null(), - } + Self::new() } } impl Stack { /// Creates a new, empty stack. pub fn new() -> Stack { - Self::default() + Self { + head: Atomic::null(), + } } /// Pushes a value on top of the stack.