Struct eventador::Eventador[][src]

pub struct Eventador { /* fields omitted */ }

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]

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

impl Clone for Eventador[src]

impl From<Arc<RingBuffer>> for Eventador[src]

Auto Trait Implementations

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> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.