Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:similar to gopl.io/ch8/pipeline1
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: 680ec67a2d84eafd31f551a7b8b2adc7510171c6d93bf31546c9935fe76d8b19
User & Date: admin 2021-10-30 21:12:12
Context
2021-10-30
21:12
similar to gopl.io/ch8/pipeline1 Leaf check-in: 680ec67a2d user: admin tags: trunk
20:43
similar to gopl.io/ch8/netcat3 , using a Tid instead of a channel check-in: 0fc740f25a user: admin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added par/4-pipeline/pipeline.d.















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import std.stdio, std.concurrency, core.thread;

void counter(Tid squarer) {
    for (int x = 0;; x++) {
        squarer.send(x);
    }
}

void squarer(Tid printer) {
    while (true) {
        auto x = receiveOnly!int;
        printer.send(x * x);
    }
}

void main() {
    spawn(&counter, spawn(&squarer, thisTid));

    while (true) {
        writeln(receiveOnly!int);
        Thread.sleep(100.msecs);
    }
}