run_worker

Function run_worker 

Source
pub fn run_worker()
Expand description

Exactly the same as run, but does not exit when empty. This is useful for threadpool workers (see run_in_thread)

Examples found in repository?
examples/threadpool.rs (line 4)
3fn main() {
4	let child = ::std::thread::spawn(|| ::transportation::run_worker()).thread().id();
5	::transportation::run_in_thread(child, || {
6		::transportation::set_timeout(|| eprintln!("Child!"), ::std::time::Duration::from_secs(1));
7	}).unwrap();
8	::std::thread::sleep(::std::time::Duration::from_secs(2));
9	::transportation::run_in_thread(child, || ::transportation::stop()).unwrap();
10	::std::thread::sleep(::std::time::Duration::from_secs(2));
11	eprintln!("{:?}", ::transportation::run_in_thread(child, || eprintln!("Alive")));
12}