Skip to content

Commit 148c4b3

Browse files
robamuAfoHT
authored andcommitted
fix the const assertion for the queue size
1 parent bbc37ca commit 148c4b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rtic-sync/src/channel.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,17 @@ impl<T, const N: usize> Default for Channel<T, N> {
7272
}
7373

7474
impl<T, const N: usize> Channel<T, N> {
75-
const _CHECK: () = assert!(N < 256, "This queue support a maximum of 255 entries");
75+
// Size check.
76+
const fn size_check() {
77+
// This limit comes from the the internal `Deque` structures used to track free and ready
78+
// slots which have a type of [u8]
79+
assert!(N < 256, "This queue support a maximum of 255 entries");
80+
}
7681

7782
/// Create a new channel.
7883
#[cfg(not(loom))]
7984
pub const fn new() -> Self {
85+
Self::size_check();
8086
Self {
8187
freeq: UnsafeCell::new(Deque::new()),
8288
readyq: UnsafeCell::new(Deque::new()),
@@ -91,6 +97,7 @@ impl<T, const N: usize> Channel<T, N> {
9197
/// Create a new channel.
9298
#[cfg(loom)]
9399
pub fn new() -> Self {
100+
Self::size_check();
94101
Self {
95102
freeq: UnsafeCell::new(Deque::new()),
96103
readyq: UnsafeCell::new(Deque::new()),

0 commit comments

Comments
 (0)