Skip to content

Commit

Permalink
refactor: demostrate how to use a background subscriber in the example (
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanYuYuan authored and gmartin82 committed Aug 21, 2024
1 parent c0a370b commit 66f2b7d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/examples/z_sub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 66f2b7d

Please sign in to comment.