Skip to content

Commit

Permalink
remove heap allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaicode committed Nov 13, 2023
1 parent 22b5e83 commit 8a5756b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

use alloc::boxed::Box;
// use alloc::boxed::Box;
use core::fmt;
use core::panic::{RefUnwindSafe, UnwindSafe};
use sync::atomic::{self, Ordering};
Expand Down Expand Up @@ -103,8 +103,8 @@ impl<T> RefUnwindSafe for ConcurrentQueue<T> {}

enum Inner<T> {
Single(Single<T>),
Bounded(Box<Bounded<T>>),
Unbounded(Box<Unbounded<T>>),
Bounded(Bounded<T>),
Unbounded(Unbounded<T>),
}

impl<T> ConcurrentQueue<T> {
Expand All @@ -127,7 +127,7 @@ impl<T> ConcurrentQueue<T> {
if cap == 1 {
ConcurrentQueue(Inner::Single(Single::new()))
} else {
ConcurrentQueue(Inner::Bounded(Box::new(Bounded::new(cap))))
ConcurrentQueue(Inner::Bounded(Bounded::new(cap)))
}
}

Expand All @@ -141,7 +141,7 @@ impl<T> ConcurrentQueue<T> {
/// let q = ConcurrentQueue::<i32>::unbounded();
/// ```
pub fn unbounded() -> ConcurrentQueue<T> {
ConcurrentQueue(Inner::Unbounded(Box::new(Unbounded::new())))
ConcurrentQueue(Inner::Unbounded(Unbounded::new()))
}

/// Attempts to push an item into the queue.
Expand Down

0 comments on commit 8a5756b

Please sign in to comment.