From e80682996e1c422aaefc80bb0f503772e4b0807a Mon Sep 17 00:00:00 2001 From: Alexey Gerasev Date: Fri, 16 Aug 2024 12:00:22 +0700 Subject: [PATCH] Make AsyncProducer::wait_vacant mutable, bump major version because it's a breaking change --- async/Cargo.toml | 2 +- async/src/traits/consumer.rs | 2 ++ async/src/traits/producer.rs | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/async/Cargo.toml b/async/Cargo.toml index 9c2a908..455520f 100644 --- a/async/Cargo.toml +++ b/async/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-ringbuf" -version = "0.2.1" +version = "0.3.0" edition.workspace = true authors.workspace = true description = "Async SPSC FIFO ring buffer" diff --git a/async/src/traits/consumer.rs b/async/src/traits/consumer.rs index f3ca8f3..7ba7711 100644 --- a/async/src/traits/consumer.rs +++ b/async/src/traits/consumer.rs @@ -29,6 +29,8 @@ pub trait AsyncConsumer: Consumer { /// Wait for the buffer to contain at least `count` items or to close. /// /// In debug mode panics if `count` is greater than buffer capacity. + /// + /// The method takes `&mut self` because only single [`WaitOccupiedFuture`] is allowed at a time. fn wait_occupied(&mut self, count: usize) -> WaitOccupiedFuture<'_, Self> { debug_assert!(count <= self.capacity().get()); WaitOccupiedFuture { diff --git a/async/src/traits/producer.rs b/async/src/traits/producer.rs index 29a2732..3171c6f 100644 --- a/async/src/traits/producer.rs +++ b/async/src/traits/producer.rs @@ -45,7 +45,9 @@ pub trait AsyncProducer: Producer { /// Wait for the buffer to have at least `count` free places for items or to close. /// /// In debug mode panics if `count` is greater than buffer capacity. - fn wait_vacant(&self, count: usize) -> WaitVacantFuture<'_, Self> { + /// + /// The method takes `&mut self` because only single [`WaitVacantFuture`] is allowed at a time. + fn wait_vacant(&mut self, count: usize) -> WaitVacantFuture<'_, Self> { debug_assert!(count <= self.capacity().get()); WaitVacantFuture { owner: self,