mod counter_abstract_process;
use counter_abstract_process::{Counter, CounterMessages, CounterRequests};
use lunatic::ap::{AbstractProcess, ProcessRef};
use lunatic::supervisor::{Supervisor, SupervisorConfig, SupervisorStrategy};
use lunatic::Mailbox;
struct Sup;
impl Supervisor for Sup {
type Arg = ();
type Children = (Counter,);
fn init(config: &mut SupervisorConfig<Self>, _: ()) {
config.set_strategy(SupervisorStrategy::OneForOne);
config.set_args((0,));
config.set_names((Some("hello".to_owned()),));
}
}
#[lunatic::main]
fn main(_: Mailbox<()>) {
Sup::start(()).unwrap();
let hello = ProcessRef::<Counter>::lookup(&"hello").unwrap();
hello.increment();
hello.increment();
assert_eq!(hello.count(), 2);
}