diff options
Diffstat (limited to 'embassy-sync/src')
| -rw-r--r-- | embassy-sync/src/channel.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index c4267064c..f9f71d026 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -620,6 +620,18 @@ where | |||
| 620 | self.lock(|c| c.try_receive()) | 620 | self.lock(|c| c.try_receive()) |
| 621 | } | 621 | } |
| 622 | 622 | ||
| 623 | /// Returns the maximum number of elements the channel can hold. | ||
| 624 | pub const fn capacity(&self) -> usize { | ||
| 625 | N | ||
| 626 | } | ||
| 627 | |||
| 628 | /// Returns the free capacity of the channel. | ||
| 629 | /// | ||
| 630 | /// This is equivalent to `capacity() - len()` | ||
| 631 | pub fn free_capacity(&self) -> usize { | ||
| 632 | N - self.len() | ||
| 633 | } | ||
| 634 | |||
| 623 | /// Returns the number of elements currently in the channel. | 635 | /// Returns the number of elements currently in the channel. |
| 624 | pub fn len(&self) -> usize { | 636 | pub fn len(&self) -> usize { |
| 625 | self.lock(|c| c.len()) | 637 | self.lock(|c| c.len()) |
