MPE/iX test tweaks from Mark Bixby.
[p5sagit/p5-mst-13.2.git] / ext / Thread / io.tx
1 BEGIN {
2     eval { require Config; import Config };
3     if ($@) {
4         print "1..0 # Skip: no Config\n";
5         exit(0);
6     }
7     if ($Config{extensions} !~ /\bThread\b/) {
8         print "1..0 # Skip: no use5005threads\n";
9         exit(0);
10     }
11 }
12
13 use Thread;
14
15 sub counter {
16 $count = 10;
17 while ($count--) {
18     sleep 1;
19     print "ping $count\n";
20 }
21 }
22
23 sub reader {
24     my $line;
25     while ($line = <STDIN>) {
26         print "reader: $line";
27     }
28     print "End of input in reader\n";
29     return 0;
30 }
31
32 print <<'EOT';
33 This test starts up a thread to read and echo whatever is typed on
34 the keyboard/stdin, line by line, while the main thread counts down
35 to zero. The test stays running until both the main thread has
36 finished counting down and the I/O thread has seen end-of-file on
37 the terminal/stdin.
38 EOT
39
40 $r = new Thread \&counter;
41
42 &reader;
43
44 __END__
45
46
47 $count = 10;
48 while ($count--) {
49     sleep 1;
50     print "ping $count\n";
51 }