projects
/
p5sagit/p5-mst-13.2.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
(retracted by #16258)
[p5sagit/p5-mst-13.2.git]
/
ext
/
threads
/
shared
/
t
/
cond.t
1
BEGIN {
2
chdir 't' if -d 't';
3
@INC = qw(../lib .);
4
require Config; import Config;
5
unless ($Config{'useithreads'}) {
6
print "1..0 # Skip: no threads\n";
7
exit 0;
8
}
9
require "test.pl";
10
}
11
print "1..4\n";
12
use strict;
13
14
use threads;
15
16
use threads::shared;
17
18
my $lock : shared;
19
20
sub foo {
21
my $ret = 0;
22
lock($lock);
23
$ret += 1;
24
cond_wait($lock);
25
$ret += 2;
26
return $ret;
27
}
28
29
sub bar {
30
my $ret = 0;
31
lock($lock);
32
$ret += 1;
33
cond_signal($lock);
34
$ret += 2;
35
return $ret;
36
}
37
38
my $tr1 = threads->create(\&foo);
39
my $tr2 = threads->create(\&bar);
40
my $rt1 = $tr1->join();
41
my $rt2 = $tr2->join();
42
ok($rt1 & 1);
43
ok($rt1 & 2);
44
ok($rt2 & 1);
45
ok($rt2 & 2);
46
47