Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions book/en/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = [
"Jorge Aparicio <[email protected]>",
"Per Lindgren <[email protected]>",
]
multilingual = false
src = "src"
title = "Real-Time Interrupt-driven Concurrency"

Expand All @@ -18,5 +17,5 @@ command = "mdbook-mermaid"

[output.html]
git-repository-url = "https://github.com/rtic-rs/rtic"
git-repository-icon = "fa-github"
git-repository-icon = "fab-github"
additional-js = ["mermaid.min.js", "mermaid-init.js"]
4 changes: 4 additions & 0 deletions rtic-sync/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ For each category, _Added_, _Changed_, _Fixed_ add new entries at the top!

## [Unreleased]

### Fixed

- Const check for `channel::Channel` size smaller than 256 is now properly evaluated.

### Changed

- Un-hide lifetimes of output type in `Signal::split` to resolve a new warning.
Expand Down
11 changes: 10 additions & 1 deletion rtic-sync/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type WaitQueue = DoublyLinkedList<WaitQueueData>;
///
/// This channel uses critical sections, however there are extremely small and all `memcpy`
/// operations of `T` are done without critical sections.
///
/// Right now, the size of the queue `N` is limited to 255 elements.
pub struct Channel<T, const N: usize> {
// Here are all indexes that are not used in `slots` and ready to be allocated.
freeq: UnsafeCell<Deque<u8, N>>,
Expand Down Expand Up @@ -72,11 +74,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()),
Expand All @@ -91,6 +99,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()),
Expand Down