mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +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> {
|
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.
|
/// Create a new channel.
|
||||||
#[cfg(not(loom))]
|
#[cfg(not(loom))]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
|
Self::size_check();
|
||||||
Self {
|
Self {
|
||||||
freeq: UnsafeCell::new(Deque::new()),
|
freeq: UnsafeCell::new(Deque::new()),
|
||||||
readyq: 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.
|
/// Create a new channel.
|
||||||
#[cfg(loom)]
|
#[cfg(loom)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
Self::size_check();
|
||||||
Self {
|
Self {
|
||||||
freeq: UnsafeCell::new(Deque::new()),
|
freeq: UnsafeCell::new(Deque::new()),
|
||||||
readyq: UnsafeCell::new(Deque::new()),
|
readyq: UnsafeCell::new(Deque::new()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue