async_queue/
async_queue.rs

1//! A sample application asynchronously printing metrics to stdout.
2
3use dipstick::{Input, InputScope, QueuedInput, Stream};
4use std::thread;
5use std::thread::sleep;
6use std::time::Duration;
7
8fn main() {
9    let async_metrics = Stream::write_to_stdout().queued(100).metrics();
10    let counter = async_metrics.counter("counter_a");
11    for _ in 0..4 {
12        let counter = counter.clone();
13        thread::spawn(move || {
14            loop {
15                // report some metric values from our "application" loop
16                counter.count(11);
17                sleep(Duration::from_millis(50));
18            }
19        });
20    }
21    sleep(Duration::from_secs(5000));
22}