should POSIX.xs use XSRETURN_UNDEF in sigaction?
[p5sagit/p5-mst-13.2.git] / ext / Thread / io.tx
CommitLineData
0fcb073c 1BEGIN {
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
d9bb3666 13use Thread;
14
17f28c40 15sub counter {
16$count = 10;
17while ($count--) {
18 sleep 1;
19 print "ping $count\n";
20}
21}
22
d9bb3666 23sub 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
609f3ea9 32print <<'EOT';
33This test starts up a thread to read and echo whatever is typed on
34the keyboard/stdin, line by line, while the main thread counts down
35to zero. The test stays running until both the main thread has
36finished counting down and the I/O thread has seen end-of-file on
37the terminal/stdin.
38EOT
39
17f28c40 40$r = new Thread \&counter;
41
42&reader;
43
44__END__
45
46
609f3ea9 47$count = 10;
d9bb3666 48while ($count--) {
49 sleep 1;
50 print "ping $count\n";
51}