Crate lunatic_cached_process
source ·Expand description
Cached process lookups with lunatic.
When a process is lookup, it is cached in the local process to avoid unnecessery future lookups. This is useful for globally registered processes and abstract processes.
Example
use lunatic::{spawn_link, test};
use lunatic_cached_process::{cached_process, CachedLookup};
cached_process! {
static COUNTER_PROCESS: Process<()> = "counter-process";
}
let process = spawn_link!(|mailbox: Mailbox<()>| { loop { } });
process.register("counter-process");
let lookup: Option<Process<T>> = COUNTER_PROCESS.get(); // First call will lookup process from lunatic runtime
assert!(lookup.is_some());
let lookup: Option<Process<T>> = COUNTER_PROCESS.get(); // Subsequent calls will use cached lookup
assert!(lookup.is_some());
Macros
- Macro for defining a process local lookup cache for processes.
Structs
- Cached process to avoid looking up a global process multiple times.
Traits
- Trait for accessing a static process local cache.