macro_rules! cached_process { ( $( $(#[$attr:meta])* $vis:vis static $ident:ident : $process_type:ident <$ty:ty $( , $s:ty )?> = $name:tt ; )+ ) => { ... }; }
Expand description
Macro for defining a process local lookup cache for processes.
The structure is as follows:
static <ident>: <process_type> = <process_name>;Where
<ident>: Static variable name.<process_type>: EitherProcess<T>,ProcessRef<T>, orProcess<T, S>whereTis the message type, andSis the serializer.<process_name>: The string literal of the process name.
Examples
Cached lunatic::Process.
use lunatic_cached_process::cached_process;
use serde::{Serialize, Deserialize};
cached_process! {
static COUNTER: Process<CountMessage> = "global-counter-process";
}
#[derive(Serialize, Deserialize)]
enum CountMessage {
Inc,
Dec,
}Cached lunatic::process::ProcessRef.
use lunatic_cached_process::cached_process;
cached_process! {
static COUNTER: ProcessRef<CounterProcess> = "global-counter-process-ref";
}
struct CounterProcess;
impl lunatic::process::AbstractProcess for CounterProcess {
type Arg = ();
type State = Self;
}