ringbuf_blocking/
alias.rs1#[cfg(feature = "std")]
2use crate::sync::StdSemaphore;
3use crate::{rb::BlockingRb, sync::Semaphore};
4use ringbuf::{storage::Array, SharedRb};
5#[cfg(feature = "alloc")]
6use ringbuf::{storage::Heap, HeapRb};
7
8#[cfg(all(feature = "alloc", not(feature = "portable-atomic")))]
9pub use alloc::sync::Arc;
10#[cfg(all(feature = "alloc", feature = "portable-atomic"))]
11pub use portable_atomic_util::Arc;
12
13#[cfg(feature = "std")]
14pub type BlockingHeapRb<T, X = StdSemaphore> = BlockingRb<Heap<T>, X>;
15#[cfg(all(feature = "alloc", not(feature = "std")))]
16pub type BlockingHeapRb<T, X> = BlockingRb<Heap<T>, X>;
17
18#[cfg(feature = "alloc")]
19impl<T, X: Semaphore> BlockingHeapRb<T, X> {
20 pub fn new(cap: usize) -> Self {
21 Self::from(HeapRb::new(cap))
22 }
23}
24
25#[cfg(feature = "std")]
26pub type BlockingStaticRb<T, const N: usize, X = StdSemaphore> = BlockingRb<Array<T, N>, X>;
27#[cfg(all(feature = "alloc", not(feature = "std")))]
28pub type BlockingStaticRb<T, const N: usize, X> = BlockingRb<Array<T, N>, X>;
29
30impl<T, const N: usize, X: Semaphore> Default for BlockingRb<Array<T, N>, X> {
31 fn default() -> Self {
32 BlockingRb::from(SharedRb::default())
33 }
34}