From 66f2b7d3c01994584998fedc4dfe9703dc60e9ca Mon Sep 17 00:00:00 2001 From: Yuyuan Yuan Date: Tue, 20 Aug 2024 23:47:51 +0800 Subject: [PATCH] refactor: demostrate how to use a background subscriber in the example (#1315) --- 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();