Skip to content

Commit

Permalink
removed unused methods from commited array
Browse files Browse the repository at this point in the history
  • Loading branch information
Athryx committed Mar 7, 2024
1 parent eab1860 commit 8534986
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
25 changes: 2 additions & 23 deletions max78000_hal/src/committed_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl CommittedArray {
inner.data_len = data.len();
inner.data[..data.len()].copy_from_slice(data);

// release synchronizes with the compare exchange acquire
self.status.store(FULL, Ordering::Release);

Ok(())
Expand All @@ -93,33 +94,11 @@ impl CommittedArray {
out.copy_from_slice(&inner.data[..inner.data_len]);
inner.data_len = 0;

// release synchronizes with the compare exchange acquire
self.status.store(EMPTY, Ordering::Release);

Ok(out)
}

pub fn is_full(&self) -> bool {
self.status.load(Ordering::Relaxed) == FULL
}

pub fn is_empty(&self) -> bool {
self.status.load(Ordering::Relaxed) == EMPTY
}

pub fn peek_len(&self) -> Option<usize> {
self.status.compare_exchange(
FULL,
BUSY,
Ordering::Acquire,
Ordering::Relaxed
).ok()?;

let len = unsafe { self.inner().data_len };

self.status.store(FULL, Ordering::Relaxed);

Some(len)
}
}

// safety: atomics synchronize access to unsafe cell
Expand Down
2 changes: 1 addition & 1 deletion max78000_hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Write for UartWriter {
}
}

// Safety: having multiple shared references to uart is fine
// FIXME: the uart is not actually sync
unsafe impl Send for Uart {}
unsafe impl Sync for Uart {}

Expand Down

0 comments on commit 8534986

Please sign in to comment.