embassy-sync: renamed field len to capacity on zerocopy_channel state

This commit is contained in:
Oliver Rockstedt 2024-10-06 17:45:03 +02:00
parent f3ed0c6026
commit 12e6add058

View File

@ -53,7 +53,7 @@ impl<'a, M: RawMutex, T> Channel<'a, M, T> {
buf: buf.as_mut_ptr(), buf: buf.as_mut_ptr(),
phantom: PhantomData, phantom: PhantomData,
state: Mutex::new(RefCell::new(State { state: Mutex::new(RefCell::new(State {
len, capacity: len,
front: 0, front: 0,
back: 0, back: 0,
full: false, full: false,
@ -259,7 +259,8 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
} }
struct State { struct State {
len: usize, /// Maximum number of elements the channel can hold.
capacity: usize,
/// Front index. Always 0..=(N-1) /// Front index. Always 0..=(N-1)
front: usize, front: usize,
@ -276,7 +277,7 @@ struct State {
impl State { impl State {
fn increment(&self, i: usize) -> usize { fn increment(&self, i: usize) -> usize {
if i + 1 == self.len { if i + 1 == self.capacity {
0 0
} else { } else {
i + 1 i + 1
@ -294,10 +295,10 @@ impl State {
if self.back >= self.front { if self.back >= self.front {
self.back - self.front self.back - self.front
} else { } else {
self.len + self.back - self.front self.capacity + self.back - self.front
} }
} else { } else {
self.len self.capacity
} }
} }