pub struct BlockingPublisher<Message> { /* private fields */ }Expand description
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.
Implementations§
Source§impl<Message: Clone> BlockingPublisher<Message>
impl<Message: Clone> BlockingPublisher<Message>
Sourcepub fn new(
required_subscribers: usize,
buffer_size: usize,
) -> BlockingPublisher<Message>
pub fn new( required_subscribers: usize, buffer_size: usize, ) -> BlockingPublisher<Message>
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.
Trait Implementations§
Source§impl<Message: 'static + Send + Clone> MessagePublisher for BlockingPublisher<Message>
impl<Message: 'static + Send + Clone> MessagePublisher for BlockingPublisher<Message>
Source§fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Message>>
fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Message>>
Reserves a space for a message with the subscribers, returning when it’s ready
Source§fn when_empty(&mut self) -> BoxFuture<'static, ()>
fn when_empty(&mut self) -> BoxFuture<'static, ()>
Waits until all subscribers have consumed all pending messages
Source§fn is_closed(&self) -> bool
fn is_closed(&self) -> bool
Returns true if this publisher is closed (will not publish any further messages to its subscribers)
Source§fn when_closed(&self) -> BoxFuture<'static, ()>
fn when_closed(&self) -> BoxFuture<'static, ()>
Future that returns when this publisher is closed