[][src]Struct flo_stream::BlockingPublisher

pub struct BlockingPublisher<Message> { /* fields omitted */ }

A blocking publisher is a publisher that blocks messages until it has enough subscribers

This is useful for cases where a publisher is being used asynchronously and wants to ensure that its messages are sent to at least one subscriber. Once the required number of subscribers is reached, this will not block again even if some subscribers are dropped.

Methods

impl<Message: Clone> BlockingPublisher<Message>[src]

pub fn new(
    required_subscribers: usize,
    buffer_size: usize
) -> BlockingPublisher<Message>
[src]

Creates a new blocking publisher

This publisher will refuse to receive any items until at least required_subscribers are connected. The buffer size indicates the number of queued items permitted per buffer.

pub fn when_fully_subscribed(
    &mut self
) -> impl Future<Output = Result<(), Canceled>>
[src]

Returns a future that will complete when this publisher has enough subscribers

This is useful as a way to avoid blocking with wait_send when setting up the publisher

Trait Implementations

impl<Message: 'static + Send + Clone> MessagePublisher for BlockingPublisher<Message>[src]

type Message = Message

fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Message>>[src]

Reserves a space for a message with the subscribers, returning when it's ready

fn when_empty(&mut self) -> BoxFuture<'static, ()>[src]

Waits until all subscribers have consumed all pending messages

Auto Trait Implementations

impl<Message> !RefUnwindSafe for BlockingPublisher<Message>

impl<Message> Send for BlockingPublisher<Message> where
    Message: Send

impl<Message> Sync for BlockingPublisher<Message> where
    Message: Send

impl<Message> Unpin for BlockingPublisher<Message>

impl<Message> !UnwindSafe for BlockingPublisher<Message>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.