loom_core_actors/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pub use actor::{Accessor, Actor, ActorResult, Consumer, Producer, WorkerResult};
pub use actor_manager::ActorsManager;
pub use channels::{Broadcaster, MultiProducer};
pub use shared_state::SharedState;

mod actor;
mod actor_manager;
mod channels;
mod shared_state;

#[macro_export]
macro_rules! run_async {
    ($fx:expr) => {
        match $fx.await {
            Ok(_) => {}
            Err(e) => error!("ERROR_RUNNING_ASYNC"),
        }
    };
}

#[inline]
pub async fn subscribe_helper<A: Clone + Send + Sync>(broadcaster: &Broadcaster<A>) -> tokio::sync::broadcast::Receiver<A> {
    broadcaster.subscribe().await
}

#[macro_export]
macro_rules! subscribe {
    ($name:ident) => {
        let mut $name = loom_core_actors::subscribe_helper(&$name).await;
    };
}