mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Add capacity, free_capacity, clear, len, is_empty and is_full functions to Channel::{Sender, Receiver}
This commit is contained in:
parent
aa2f6ae965
commit
baef775f6b
@ -9,6 +9,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}`.
|
||||
|
||||
## 0.6.0 - 2024-05-29
|
||||
|
||||
|
@ -72,6 +72,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 [`Channel::capacity()`]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.channel.capacity()
|
||||
}
|
||||
|
||||
/// Returns the free capacity of the channel.
|
||||
///
|
||||
/// See [`Channel::free_capacity()`]
|
||||
pub fn free_capacity(&self) -> usize {
|
||||
self.channel.free_capacity()
|
||||
}
|
||||
|
||||
/// Clears all elements in the channel.
|
||||
///
|
||||
/// See [`Channel::clear()`]
|
||||
pub fn clear(&self) {
|
||||
self.channel.clear();
|
||||
}
|
||||
|
||||
/// Returns the number of elements currently in the channel.
|
||||
///
|
||||
/// See [`Channel::len()`]
|
||||
pub fn len(&self) -> usize {
|
||||
self.channel.len()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is empty.
|
||||
///
|
||||
/// See [`Channel::is_empty()`]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.channel.is_empty()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is full.
|
||||
///
|
||||
/// See [`Channel::is_full()`]
|
||||
pub fn is_full(&self) -> bool {
|
||||
self.channel.is_full()
|
||||
}
|
||||
}
|
||||
|
||||
/// Send-only access to a [`Channel`] without knowing channel size.
|
||||
@ -179,6 +221,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 [`Channel::capacity()`]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.channel.capacity()
|
||||
}
|
||||
|
||||
/// Returns the free capacity of the channel.
|
||||
///
|
||||
/// See [`Channel::free_capacity()`]
|
||||
pub fn free_capacity(&self) -> usize {
|
||||
self.channel.free_capacity()
|
||||
}
|
||||
|
||||
/// Clears all elements in the channel.
|
||||
///
|
||||
/// See [`Channel::clear()`]
|
||||
pub fn clear(&self) {
|
||||
self.channel.clear();
|
||||
}
|
||||
|
||||
/// Returns the number of elements currently in the channel.
|
||||
///
|
||||
/// See [`Channel::len()`]
|
||||
pub fn len(&self) -> usize {
|
||||
self.channel.len()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is empty.
|
||||
///
|
||||
/// See [`Channel::is_empty()`]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.channel.is_empty()
|
||||
}
|
||||
|
||||
/// Returns whether the channel is full.
|
||||
///
|
||||
/// See [`Channel::is_full()`]
|
||||
pub fn is_full(&self) -> bool {
|
||||
self.channel.is_full()
|
||||
}
|
||||
}
|
||||
|
||||
/// Receive-only access to a [`Channel`] without knowing channel size.
|
||||
|
Loading…
Reference in New Issue
Block a user