Skip to main content

threadless/
threadless.rs

1use timely::dataflow::{InputHandle, ProbeHandle};
2use timely::dataflow::operators::{Inspect, Probe};
3use timely::WorkerConfig;
4
5fn main() {
6
7    // create a naked single-threaded worker.
8    let allocator = timely::communication::Allocator::Thread(
9        timely::communication::allocator::Thread::default(),
10    );
11    let mut worker = timely::worker::Worker::new(WorkerConfig::default(), allocator, None);
12
13    // create input and probe handles.
14    let mut input = InputHandle::new();
15    let probe = ProbeHandle::new();
16
17    // directly build a dataflow.
18    worker.dataflow(|scope| {
19        input
20            .to_stream(scope)
21            .container::<Vec<_>>()
22            .inspect(|x| println!("{:?}", x))
23            .probe_with(&probe);
24    });
25
26    // manage inputs.
27    for i in 0 .. 10 {
28        input.send(i);
29        input.advance_to(i);
30        while probe.less_than(input.time()) {
31            worker.step();
32        }
33    }
34}