use std::time::Duration;
use lunatic::host::process_id;
use lunatic::{sleep, Mailbox, Process, ProcessConfig};
#[lunatic::main]
fn main(_: Mailbox<()>) {
let mut config = ProcessConfig::new().unwrap();
config.set_max_memory(1_500_000);
config.set_max_fuel(1);
Process::spawn_config(&config, (), |_, _: Mailbox<()>| {
println!("Process {} trying to allocate 2MB", process_id());
let temp: Vec<u8> = vec![0; 2_000_000];
println!("Succeeded. Value at index 0: {}", temp[0]);
});
Process::spawn_config(&config, (), |_, _: Mailbox<()>| {
println!("Process {} going into infinite loop", process_id());
loop {}
});
sleep(Duration::from_millis(200));
}