Struct eventador::Eventador [−][src]
A lock-free and thread-safe event-bus implementation
Example
Basic usage:
let eventbus = Eventador::new(4)?; let subscriber = eventbus.subscribe::<usize>(); let mut i: usize = 1234; eventbus.publish(i); let mut msg = subscriber.recv().unwrap(); assert_eq!(i, *msg);
Implementations
impl Eventador
[src]
pub fn new(capacity: u64) -> Result<Self>
[src]
Creates a new Eventador event-bus
The capacity is required to be a power of 2.
Example
Basic usage:
let eventbus = Eventador::new(4)?;
pub fn publish<T: 'static + Send>(&self, message: T)
[src]
Publishes an event on the event-bus
Example
Basic usage:
let eventbus = Eventador::new(4)?; let mut i: usize = 1234; eventbus.publish(i);
pub fn subscribe<T: 'static + Send>(&self) -> Subscriber<'_, T>
[src]
Creates a Subscriber
that is subscribed to events of the provided type
The Subscriber
will not receive intended events that were published to the event-bus
before time of subscription. It will only receive intended events that are published after
time of subscription.
Example
Basic usage:
let eventbus = Eventador::new(4)?; // subscribe first, before publishing! let subscriber = eventbus.subscribe::<usize>(); let mut i: usize = 1234; eventbus.publish(i); let mut msg = subscriber.recv().unwrap(); assert_eq!(i, *msg);
pub fn async_publisher<T: 'static + Send + Unpin>(&self) -> AsyncPublisher<T>
[src]
Creates an AsyncPublisher
that can publish to the event-bus asynchronously
Example
Basic usage:
let eventbus = Eventador::new(4)?; let mut publisher: AsyncPublisher<usize> = eventbus.async_publisher(); let mut i: usize = 1234; publisher.send(i).await?;
pub fn async_subscriber<T: 'static + Send + Unpin>(
&self
) -> AsyncSubscriber<'_, T>
[src]
&self
) -> AsyncSubscriber<'_, T>
Creates an AsyncSubscriber
that can subscribe to events and receive them asynchronously
Example
Basic usage:
let eventbus = Eventador::new(4)?; let subscriber = disruptor.async_subscriber::<usize>(); let mut publisher: AsyncPublisher<usize> = disruptor.async_publisher(); let mut i: usize = 1234; publisher.send(i).await?; let mut msg = subscriber.recv().await.unwrap(); assert_eq!(i, *msg);
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Eventador
[src]
impl Send for Eventador
[src]
impl Sync for Eventador
[src]
impl Unpin for Eventador
[src]
impl !UnwindSafe for Eventador
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,