This library contains higher level wrappers for low level Lunatic syscalls.
Create 1_000 child processes and calculate the sum of numbers from 0 to i in each child process, then send the result back to the parent process and print it.
```rust use lunatic::{Channel, Process};
fn main() {
let channel = Channel::new(0);
let vec: Vec
for i in vec.iter() {
Process::spawn((*i, vec.clone(), channel.clone()), child).unwrap();
}
for _ in vec.iter() {
let (i, sum) = channel.receive();
println!("Sum until {}: {}", i, sum);
}
}
// Child process calculates the sum of numbers of context.1 until context.0 index.
fn child(context: (i32, Vec
Compile your app to a WebAssembly target:
cargo build --release --target=wasm32-wasi
and run it with
lunatic target/wasm32-wasi/release/<name>.wasm