[−][src]Struct multistream_batch::channel::buf_batch::BufBatchChannel
Batches items in internal buffer up to max_size
items or until max_duration
has elapsed
since first item was appended to the batch.
Methods
impl<I: Debug> BufBatchChannel<I>
[src]
pub fn new(
max_size: usize,
max_duration: Duration,
channel_size: usize
) -> (Sender<Command<I>>, BufBatchChannel<I>)
[src]
max_size: usize,
max_duration: Duration,
channel_size: usize
) -> (Sender<Command<I>>, BufBatchChannel<I>)
Creates batch given maximum batch size in number of items (max_size
)
and maximum duration that batch can last (max_duration
) since first item appended to it.
It also returns Sender
endpoint into which Command
s can be sent.
Panics if max_size
== 0.
pub fn with_producer_thread(
max_size: usize,
max_duration: Duration,
channel_size: usize,
producer: impl FnOnce(Sender<Command<I>>) + Send + 'static
) -> BufBatchChannel<I> where
I: Send + 'static,
[src]
max_size: usize,
max_duration: Duration,
channel_size: usize,
producer: impl FnOnce(Sender<Command<I>>) + Send + 'static
) -> BufBatchChannel<I> where
I: Send + 'static,
Crates batch calling producer
closure with Sender
end of the channel in newly started thread.
pub fn next(&mut self) -> Result<Drain<I>, EndOfStreamError>
[src]
Gets next ready batch as Drain
iterator of its items.
This call will block until batch becomes ready.
Returns Err(EndOfStreamError)
after Sender
end was dropped and all batched items were flushed.
pub fn is_disconnected(&self) -> bool
[src]
Checks if previous self.next()
call found channel to be disconnected.
pub fn clear(&mut self)
[src]
Starts new batch dropping all buffered items.
pub fn drain(&mut self) -> Drain<I>
[src]
Starts new batch by draining all buffered items.
pub fn into_vec(self) -> Vec<I>
[src]
Converts into internal item buffer.
pub fn as_slice(&self) -> &[I]
[src]
Returns slice of internal item buffer.
Trait Implementations
Auto Trait Implementations
impl<I> Unpin for BufBatchChannel<I> where
I: Unpin,
I: Unpin,
impl<I> Sync for BufBatchChannel<I> where
I: Send + Sync,
I: Send + Sync,
impl<I> Send for BufBatchChannel<I> where
I: Send,
I: Send,
impl<I> UnwindSafe for BufBatchChannel<I> where
I: UnwindSafe,
I: UnwindSafe,
impl<I> RefUnwindSafe for BufBatchChannel<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,