From baa5fa5f026d464b0a00133dab274f4ff93db0a0 Mon Sep 17 00:00:00 2001 From: yuanyuyuan Date: Tue, 20 Aug 2024 17:03:24 +0800 Subject: [PATCH] refactor: demostrate how to use a background subscriber in the example --- examples/examples/z_sub_thr.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/examples/z_sub_thr.rs b/examples/examples/z_sub_thr.rs index fa78b4688a..78626d1d1d 100644 --- a/examples/examples/z_sub_thr.rs +++ b/examples/examples/z_sub_thr.rs @@ -78,7 +78,7 @@ fn main() { let key_expr = "test/thr"; let mut stats = Stats::new(n); - let _sub = session + session .declare_subscriber(key_expr) .callback_mut(move |_sample| { stats.increment(); @@ -87,7 +87,9 @@ fn main() { } }) .wait() - .unwrap(); + .unwrap() + // Make the subscriber run in background, until the session is closed. + .background(); println!("Press CTRL-C to quit..."); std::thread::park();