Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
caass committed Jun 19, 2024
1 parent 8d1f393 commit 435933f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl<T: Copy> Default for LockFreeFrozenVec<T> {
/// any heap allocations until the first time data is pushed to it.
fn default() -> Self {
Self {
data: std::array::from_fn(|_| Self::null()),
data: [const { Self::null() }; NUM_BUFFERS],
len: AtomicUsize::new(0),
locked: AtomicBool::new(false),
}
Expand Down Expand Up @@ -910,7 +910,7 @@ fn test_non_lockfree_unchecked() {

impl<T: Copy + Clone> Clone for LockFreeFrozenVec<T> {
fn clone(&self) -> Self {
let mut coppied_data = std::array::from_fn(|_| Self::null());
let mut coppied_data = [const { Self::null() }; NUM_BUFFERS];
// for each buffer, copy the data
self.for_each_buffer(|buffer_slice, buffer_index| {
// allocate a new buffer
Expand All @@ -931,6 +931,8 @@ impl<T: Copy + Clone> Clone for LockFreeFrozenVec<T> {

Self {
data: coppied_data,
// Since stores always use `Ordering::Release`, this call to `self.len()` (which uses `Ordering::Acquire`) reults
// in the operation overall being `Ordering::Relaxed`
len: AtomicUsize::new(self.len()),
locked: AtomicBool::new(false),
}
Expand Down

0 comments on commit 435933f

Please sign in to comment.