async_unload/
async-unload.rs1extern crate likemod;
10extern crate tokio;
11
12use std::{num, process, time};
13use tokio::runtime::current_thread;
14use tokio::timer::timeout;
15
16fn main() {
17 let modname = std::env::args().nth(1).expect("missing module name");
19
20 let pause_ms = num::NonZeroU64::new(500).unwrap();
23 let modunload = likemod::ModUnloader::new().unload_async(&modname, pause_ms);
24 let tout = time::Duration::from_secs(15);
25 let fut = timeout::Timeout::new(modunload, tout);
26
27 if let Err(err) = current_thread::block_on_all(fut) {
29 eprintln!("FAILED: {:?}", err);
30 process::exit(1)
31 }
32
33 println!("module '{}' unloaded.", modname);
35}