mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 12:55:23 +01:00
fix the const assertion for the queue size
This commit is contained in:
parent
bbc37ca3fe
commit
148c4b3cc0
1 changed files with 8 additions and 1 deletions
|
|
@ -72,11 +72,17 @@ impl<T, const N: usize> Default for Channel<T, N> {
|
|||
}
|
||||
|
||||
impl<T, const N: usize> Channel<T, N> {
|
||||
const _CHECK: () = assert!(N < 256, "This queue support a maximum of 255 entries");
|
||||
// Size check.
|
||||
const fn size_check() {
|
||||
// This limit comes from the the internal `Deque` structures used to track free and ready
|
||||
// slots which have a type of [u8]
|
||||
assert!(N < 256, "This queue support a maximum of 255 entries");
|
||||
}
|
||||
|
||||
/// Create a new channel.
|
||||
#[cfg(not(loom))]
|
||||
pub const fn new() -> Self {
|
||||
Self::size_check();
|
||||
Self {
|
||||
freeq: UnsafeCell::new(Deque::new()),
|
||||
readyq: UnsafeCell::new(Deque::new()),
|
||||
|
|
@ -91,6 +97,7 @@ impl<T, const N: usize> Channel<T, N> {
|
|||
/// Create a new channel.
|
||||
#[cfg(loom)]
|
||||
pub fn new() -> Self {
|
||||
Self::size_check();
|
||||
Self {
|
||||
freeq: UnsafeCell::new(Deque::new()),
|
||||
readyq: UnsafeCell::new(Deque::new()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue