Crates.io | lunatic-cached-process |
lib.rs | lunatic-cached-process |
version | 0.2.3 |
source | src |
created_at | 2023-02-23 10:06:04.377609 |
updated_at | 2023-04-17 05:16:04.646618 |
description | Cached process lookups with lunatic. |
homepage | |
repository | https://github.com/tqwewe/lunatic-cached-process |
max_upload_size | |
id | 792533 |
size | 29,632 |
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.
use lunatic::{spawn_link, Process};
use lunatic_cached_process::{cached_process, CachedLookup};
cached_process! {
static COUNTER_PROCESS: Process<()> = "counter-process";
}
fn main() {
let process = spawn_link!(|_mailbox: Mailbox<()>| { loop {} });
process.register("counter-process");
let lookup: Option<Process<()>> = COUNTER_PROCESS.get(); // First call lookup process from host
assert!(lookup.is_some());
let lookup: Option<Process<()>> = COUNTER_PROCESS.get(); // Subsequent calls will use cached process
assert!(lookup.is_some());
}
For more examples, see the examples directory.
Licensed under either
at your option.