pub struct StreamProducer<Q>where
Q: BbqHandle,{ /* private fields */ }Expand description
A producer handle that may write data into the buffer
Implementations§
Source§impl<Q> StreamProducer<Q>where
Q: BbqHandle,
impl<Q> StreamProducer<Q>where
Q: BbqHandle,
Sourcepub fn grant_max_remaining(
&self,
max: usize,
) -> Result<StreamGrantW<Q>, WriteGrantError>
pub fn grant_max_remaining( &self, max: usize, ) -> Result<StreamGrantW<Q>, WriteGrantError>
Obtain a grant UP TO the given max size.
If we return a grant, it will have a nonzero amount of space.
If the grant represents LESS than max size, this is due to either:
- There is less than
maxfree space available in the queue for writing - The grant represents the remaining space in the buffer that WOULDN’T cause a wrap-around of the ring buffer
This method will never cause an “early wraparound” of the ring buffer unless
there is no capacity without wrapping around. There may still be available
writing capacity in the buffer after commiting this write grant, so it may be
useful to call grant_max_remaining in a loop until Err(WriteGrantError::InsufficientSize)
is returned.
Sourcepub fn grant_exact(&self, sz: usize) -> Result<StreamGrantW<Q>, WriteGrantError>
pub fn grant_exact(&self, sz: usize) -> Result<StreamGrantW<Q>, WriteGrantError>
Obtain a grant with EXACTLY sz capacity
Unlike grant_max_remaining, if there is insufficient size at the “tail” of
the ring buffer, this method WILL cause a wrap-around to occur to attempt to
find the requested write capacity.
Source§impl<Q> StreamProducer<Q>
impl<Q> StreamProducer<Q>
Sourcepub async fn wait_grant_max_remaining(&self, max: usize) -> StreamGrantW<Q>
pub async fn wait_grant_max_remaining(&self, max: usize) -> StreamGrantW<Q>
Wait for a grant of any size, up to max, to become available
Sourcepub async fn wait_grant_exact(&self, sz: usize) -> StreamGrantW<Q>
pub async fn wait_grant_exact(&self, sz: usize) -> StreamGrantW<Q>
Wait for a grant of EXACTLY sz to become available.
If sz exceeds the capacity of the buffer, this method will never return.