1 package Thread::Semaphore;
2 use Thread qw(cond_wait cond_broadcast);
6 my $val = @_ ? shift : 1;
11 use attrs qw(locked method);
13 my $inc = @_ ? shift : 1;
14 cond_wait $s until $$s >= $inc;
19 use attrs qw(locked method);
21 my $inc = @_ ? shift : 1;
22 ($$s += $inc) > 0 and cond_broadcast $s;