pub struct JoinHandle { /* private fields */ }
Implementations§
Source§impl JoinHandle
impl JoinHandle
Sourcepub fn join(&mut self)
pub fn join(&mut self)
wait the log thread exit, can be called multiple times, but only takes effect for the first time.
Examples found in repository?
examples/formater.rs (line 24)
9fn main() {
10 let formater = BaseFormater::new().formater(format);
11
12 let mut handle = NonblockLogger::new()
13 .formater(formater)
14 .log_to_stdout()
15 .map_err(|e| eprintln!("failed to init nonblock_logger: {:?}", e))
16 .unwrap();
17
18 let now = time::Instant::now();
19
20 include!("log.snippet");
21
22 println!("join0_{}: {:?}", messages_in_channel(), now.elapsed());
23
24 handle.join();
25
26 println!("join1_{}: {:?}", messages_in_channel(), now.elapsed());
27}
More examples
examples/basic.rs (line 25)
7fn main() {
8 let mut handle = NonblockLogger::new()
9 .log_to_stdout()
10 .map_err(|e| eprintln!("failed to init nonblock_logger: {:?}", e))
11 .unwrap();
12
13 let now = time::Instant::now();
14
15 include!("log.snippet");
16 if log_enabled!(Info) {
17 println!("INFO enabled");
18 }
19
20 println!("join0_{}: {:?}", messages_in_channel(), now.elapsed());
21
22 // let _: usize = fatal!("fatal!() will return !");
23
24 // wait for log thread
25 handle.join();
26
27 println!("join1_{}: {:?}", messages_in_channel(), now.elapsed());
28}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JoinHandle
impl !RefUnwindSafe for JoinHandle
impl Send for JoinHandle
impl Sync for JoinHandle
impl Unpin for JoinHandle
impl !UnwindSafe for JoinHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more