1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* The point of this simplistic example is to demonstrate how WITHOUT `ppipe`, every iteration moves
* the corresponding item along the pipeline and then executes, in this case, the `for` loop's
* body. The items are never pre-loaded into some buffer waiting for the iteration variable to take
* ownership after being forced to move along the pipeline. This is almost never idealistic; why
* limit yourself to serial processing when you have Rust's powerful parallel processing at hand?
* This is what `ppipe` does. WITH `ppipe`, all previous iterator adaptors are ran regardless of what
* iteration, in this case, the `for` loop is on, including any previous `ppipe` adaptors which are
* busy doing their own thing. Every item that is processed is put in a buffer which can be
* accessed as it is being added to, and if there are no items in the buffer, the iteration will
* simply block until an item is available, or break if there are no more items being processed.
* This means items can be added to the buffer as you are iterating over previous items in the
* buffer, which ultimately reduces bottlenecking and GREATLY increases performance!
*/
extern crate ppipe;
use *;
use sleep;
use Duration;