#lookup #lunatic #cache

lunatic-cached-process

Cached process lookups with lunatic

6 releases

0.2.3 Apr 17, 2023
0.2.2 Mar 7, 2023
0.1.1 Feb 23, 2023

#376 in Memory management

Download history 3/week @ 2024-02-26 90/week @ 2024-04-01

90 downloads per month

Apache-2.0/MIT

12KB
144 lines

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, 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.

License

Licensed under either

at your option.

Dependencies

~2.5MB
~52K SLoC