mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Add capacity, free_capacity, clear, len, is_empty and is_full functions to priority_channel::{Sender, Receiver}
This commit is contained in:
parent
07748131dd
commit
2704ac3d28
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Add LazyLock sync primitive.
|
||||
- Add `clear`, `len`, `is_empty` and `is_full` functions to `zerocopy_channel`.
|
||||
- Add `capacity`, `free_capacity`, `clear`, `len`, `is_empty` and `is_full` functions to `channel::{Sender, Receiver}`.
|
||||
- Add `capacity`, `free_capacity`, `clear`, `len`, `is_empty` and `is_full` functions to `priority_channel::{Sender, Receiver}`.
|
||||
|
||||
## 0.6.0 - 2024-05-29
|
||||
|
||||
|
@ -71,6 +71,48 @@ where
|
||||
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
self.channel.poll_ready_to_send(cx)
|
||||
}
|
||||
|
||||
/// Returns the maximum number of elements the channel can hold.
|
||||
///
|
||||
/// See [`PriorityChannel::capacity()`]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.channel.capacity()
|
||||
}
|
||||
|
||||
/// Returns the free capacity of the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::free_capacity()`]
|
||||
pub fn free_capacity(&self) -> usize {
|
||||
self.channel.free_capacity()
|
||||
}
|
||||
|
||||
/// Clears all elements in the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::clear()`]
|
||||
pub fn clear(&self) {
|
||||
self.channel.clear();
|
||||
}
|
||||
|
||||
/// Returns the number of elements currently in the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::len()`]
|
||||
pub fn len(&self) -> usize {
|
||||
self.channel.len()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is empty.
|
||||
///
|
||||
/// See [`PriorityChannel::is_empty()`]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.channel.is_empty()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is full.
|
||||
///
|
||||
/// See [`PriorityChannel::is_full()`]
|
||||
pub fn is_full(&self) -> bool {
|
||||
self.channel.is_full()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ch, M, T, K, const N: usize> From<Sender<'ch, M, T, K, N>> for DynamicSender<'ch, T>
|
||||
@ -146,6 +188,48 @@ where
|
||||
pub fn poll_receive(&self, cx: &mut Context<'_>) -> Poll<T> {
|
||||
self.channel.poll_receive(cx)
|
||||
}
|
||||
|
||||
/// Returns the maximum number of elements the channel can hold.
|
||||
///
|
||||
/// See [`PriorityChannel::capacity()`]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.channel.capacity()
|
||||
}
|
||||
|
||||
/// Returns the free capacity of the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::free_capacity()`]
|
||||
pub fn free_capacity(&self) -> usize {
|
||||
self.channel.free_capacity()
|
||||
}
|
||||
|
||||
/// Clears all elements in the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::clear()`]
|
||||
pub fn clear(&self) {
|
||||
self.channel.clear();
|
||||
}
|
||||
|
||||
/// Returns the number of elements currently in the channel.
|
||||
///
|
||||
/// See [`PriorityChannel::len()`]
|
||||
pub fn len(&self) -> usize {
|
||||
self.channel.len()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is empty.
|
||||
///
|
||||
/// See [`PriorityChannel::is_empty()`]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.channel.is_empty()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is full.
|
||||
///
|
||||
/// See [`PriorityChannel::is_full()`]
|
||||
pub fn is_full(&self) -> bool {
|
||||
self.channel.is_full()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ch, M, T, K, const N: usize> From<Receiver<'ch, M, T, K, N>> for DynamicReceiver<'ch, T>
|
||||
|
Loading…
Reference in New Issue
Block a user