mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-02 14:54:30 +00:00
improvements for documentation
This commit is contained in:
parent
3f9f5a1f5f
commit
0f20e40dd0
88
src/lib.rs
88
src/lib.rs
@ -43,28 +43,84 @@
|
|||||||
//!
|
//!
|
||||||
//! List of currently implemented data structures:
|
//! List of currently implemented data structures:
|
||||||
# -- like `std::sync::Arc` but backed by a lock-free memory pool rather than `#[global_allocator]`"
|
arm_llsc,
|
||||||
|
all(
|
||||||
|
target_pointer_width = "32",
|
||||||
|
any(target_has_atomic = "64", feature = "portable-atomic")
|
||||||
|
),
|
||||||
|
all(
|
||||||
|
target_pointer_width = "64",
|
||||||
|
any(
|
||||||
|
all(target_has_atomic = "128", feature = "nightly"),
|
||||||
|
feature = "portable-atomic"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
doc = "- [Arc][pool::arc::Arc] -- like `std::sync::Arc` but backed by a lock-free memory pool rather than [global_allocator]"
|
||||||
)]
|
)]
|
||||||
# -- like `std::boxed::Box` but backed by a lock-free memory pool rather than `#[global_allocator]`"
|
arm_llsc,
|
||||||
|
all(
|
||||||
|
target_pointer_width = "32",
|
||||||
|
any(target_has_atomic = "64", feature = "portable-atomic")
|
||||||
|
),
|
||||||
|
all(
|
||||||
|
target_pointer_width = "64",
|
||||||
|
any(
|
||||||
|
all(target_has_atomic = "128", feature = "nightly"),
|
||||||
|
feature = "portable-atomic"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
doc = "- [Box][pool::boxed::Box] -- like `std::boxed::Box` but backed by a lock-free memory pool rather than [global_allocator]"
|
||||||
)]
|
)]
|
||||||
//! - [`BinaryHeap`] -- priority queue
|
|
||||||
//! - [`Deque`] -- double-ended queue
|
|
||||||
//! - [`HistoryBuffer`] -- similar to a write-only ring buffer
|
|
||||||
//! - [`IndexMap`] -- hash table
|
|
||||||
//! - [`IndexSet`] -- hash set
|
|
||||||
//! - [`LinearMap`]
|
|
||||||
# -- objects managed by an object pool"
|
arm_llsc,
|
||||||
|
all(
|
||||||
|
target_pointer_width = "32",
|
||||||
|
any(target_has_atomic = "64", feature = "portable-atomic")
|
||||||
|
),
|
||||||
|
all(
|
||||||
|
target_pointer_width = "64",
|
||||||
|
any(
|
||||||
|
all(target_has_atomic = "128", feature = "nightly"),
|
||||||
|
feature = "portable-atomic"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
doc = "- [Arc][pool::arc::Arc] -- like `std::sync::Arc` but backed by a lock-free memory pool rather than [global_allocator]"
|
||||||
)]
|
)]
|
||||||
//! - [`sorted_linked_list::SortedLinkedList`]
|
#![cfg_attr(
|
||||||
//! - [`String`]
|
any(
|
||||||
//! - [`Vec`]
|
arm_llsc,
|
||||||
|
all(
|
||||||
|
target_pointer_width = "32",
|
||||||
|
any(target_has_atomic = "64", feature = "portable-atomic")
|
||||||
|
),
|
||||||
|
all(
|
||||||
|
target_pointer_width = "64",
|
||||||
|
any(
|
||||||
|
all(target_has_atomic = "128", feature = "nightly"),
|
||||||
|
feature = "portable-atomic"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
doc = "- [Object](pool::object::Object) -- objects managed by an object pool"
|
||||||
|
)]
|
||||||
|
//! - [BinaryHeap] -- priority queue
|
||||||
|
//! - [Deque] -- double-ended queue
|
||||||
|
//! - [HistoryBuffer] -- similar to a write-only ring buffer
|
||||||
|
//! - [IndexMap] -- hash table
|
||||||
|
//! - [IndexSet] -- hash set
|
||||||
|
//! - [LinearMap]
|
||||||
|
//! - [sorted_linked_list::SortedLinkedList]
|
||||||
|
//! - [String]
|
||||||
|
//! - [Vec]
|
||||||
//! - [`mpmc::Q*`](mpmc) -- multiple producer multiple consumer lock-free queue
|
//! - [`mpmc::Q*`](mpmc) -- multiple producer multiple consumer lock-free queue
|
||||||
//! - [`spsc::Queue`] -- single producer single consumer lock-free queue
|
//! - [spsc] and [spsc::Queue] -- single producer single consumer lock-free queue
|
||||||
//!
|
//!
|
||||||
//! # Minimum Supported Rust Version (MSRV)
|
//! # Minimum Supported Rust Version (MSRV)
|
||||||
//!
|
//!
|
||||||
|
18
src/spsc.rs
18
src/spsc.rs
@ -1,8 +1,8 @@
|
|||||||
//! A fixed capacity Single Producer Single Consumer (SPSC) queue.
|
//! # A fixed capacity Single Producer Single Consumer (SPSC) queue.
|
||||||
//!
|
//!
|
||||||
//! Implementation based on <https://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular>
|
//! Implementation based on <https://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular>
|
||||||
//!
|
//!
|
||||||
//! # Portability
|
//! ## Portability
|
||||||
//!
|
//!
|
||||||
//! This module requires CAS atomic instructions which are not available on all architectures
|
//! This module requires CAS atomic instructions which are not available on all architectures
|
||||||
//! (e.g. ARMv6-M (`thumbv6m-none-eabi`) and MSP430 (`msp430-none-elf`)). These atomics can be
|
//! (e.g. ARMv6-M (`thumbv6m-none-eabi`) and MSP430 (`msp430-none-elf`)). These atomics can be
|
||||||
@ -10,9 +10,9 @@
|
|||||||
//! enabled with the `cas` feature and is enabled by default for `thumbv6m-none-eabi` and `riscv32`
|
//! enabled with the `cas` feature and is enabled by default for `thumbv6m-none-eabi` and `riscv32`
|
||||||
//! targets.
|
//! targets.
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! - `Queue` can be used as a plain queue
|
//! - [Queue] can be used as a plain queue
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use heapless::spsc::Queue;
|
//! use heapless::spsc::Queue;
|
||||||
@ -27,12 +27,16 @@
|
|||||||
//! assert_eq!(rb.dequeue(), Some(0));
|
//! assert_eq!(rb.dequeue(), Some(0));
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! - `Queue` can be `split` and then be used in Single Producer Single Consumer mode.
|
//! - [Queue] can be [Queue::split] and then be used in Single Producer Single Consumer mode.
|
||||||
//!
|
//!
|
||||||
//! "no alloc" applications can create a `&'static mut` reference to a `Queue` -- using a static
|
//! "no alloc" applications can create a `&'static mut` reference to a `Queue` -- using a static
|
||||||
//! variable -- and then `split` it: this consumes the static reference. The resulting `Consumer`
|
//! variable -- and then `split` it: this consumes the static reference. The resulting `Consumer`
|
||||||
//! and `Producer` can then be moved into different execution contexts (threads, interrupt handlers,
|
//! and `Producer` can then be moved into different execution contexts (threads, interrupt handlers,
|
||||||
//! etc.)
|
//! etc.).
|
||||||
|
//!
|
||||||
|
//! Alternatively, you can also create the Queue statically in the global scope by wrapping it with
|
||||||
|
//! a [static_cell](https://docs.rs/static_cell/latest/static_cell/)
|
||||||
|
//!
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use heapless::spsc::{Producer, Queue};
|
//! use heapless::spsc::{Producer, Queue};
|
||||||
@ -43,6 +47,8 @@
|
|||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
|
//! // Alternatively, use something like `static_cell` to create the `Queue` in the global
|
||||||
|
//! // scope.
|
||||||
//! let queue: &'static mut Queue<Event, 4> = {
|
//! let queue: &'static mut Queue<Event, 4> = {
|
||||||
//! static mut Q: Queue<Event, 4> = Queue::new();
|
//! static mut Q: Queue<Event, 4> = Queue::new();
|
||||||
//! unsafe { &mut Q }
|
//! unsafe { &mut Q }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user