diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-19 10:25:46 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-19 10:25:46 +0000 |
commit | 34d676f12ecdcb32c64fe75fdc59168709fa30ea (patch) | |
tree | 4e74b95e2003348d285ac2eee53aaa466357b61e /ext/Thread/sync.tx | |
parent | 186e602c1889f6ee5b887f8ac155dcb15661cfa1 (diff) | |
download | perl-34d676f12ecdcb32c64fe75fdc59168709fa30ea.tar.gz |
Rename the old non-standard threads tests so that
they won't be invoked.
p4raw-id: //depot/perl@10711
Diffstat (limited to 'ext/Thread/sync.tx')
-rw-r--r-- | ext/Thread/sync.tx | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/ext/Thread/sync.tx b/ext/Thread/sync.tx new file mode 100644 index 0000000000..c5cf1a754f --- /dev/null +++ b/ext/Thread/sync.tx @@ -0,0 +1,72 @@ +BEGIN { + eval { require Config; import Config }; + if ($@) { + print "1..0 # Skip: no Config\n"; + exit(0); + } + if ($Config{extensions} !~ /\bThread\b/) { + print "1..0 # Skip: no use5005threads\n"; + exit(0); + } +} + +use Thread; + +$level = 0; + +sub single_file : locked { + my $arg = shift; + $level++; + print "Level $level for $arg\n"; + print "(something is wrong)\n" if $level < 0 || $level > 1; + sleep 1; + $level--; + print "Back to level $level\n"; +} + +sub start_bar { + my $i; + print "start bar\n"; + for $i (1..3) { + print "bar $i\n"; + single_file("bar $i"); + sleep 1 if rand > 0.5; + } + print "end bar\n"; + return 1; +} + +sub start_foo { + my $i; + print "start foo\n"; + for $i (1..3) { + print "foo $i\n"; + single_file("foo $i"); + sleep 1 if rand > 0.5; + } + print "end foo\n"; + return 1; +} + +sub start_baz { + my $i; + print "start baz\n"; + for $i (1..3) { + print "baz $i\n"; + single_file("baz $i"); + sleep 1 if rand > 0.5; + } + print "end baz\n"; + return 1; +} + +$| = 1; +srand($$^$^T); + +$foo = new Thread \&start_foo; +$bar = new Thread \&start_bar; +$baz = new Thread \&start_baz; +$foo->join(); +$bar->join(); +$baz->join(); +print "main: threads finished, exiting\n"; |