1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | Coro::Semaphore - non-binary semaphores |
3 | Coro::Semaphore - counting semaphores |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use Coro::Semaphore; |
7 | use Coro::Semaphore; |
8 | |
8 | |
… | |
… | |
35 | |
35 | |
36 | no warnings; |
36 | no warnings; |
37 | |
37 | |
38 | use Coro (); |
38 | use Coro (); |
39 | |
39 | |
40 | $VERSION = 5.0; |
40 | $VERSION = 5.131; |
41 | |
41 | |
42 | =item new [inital count] |
42 | =item new [inital count] |
43 | |
43 | |
44 | Creates a new sempahore object with the given initial lock count. The |
44 | Creates a new sempahore object with the given initial lock count. The |
45 | default lock count is 1, which means it is unlocked by default. Zero (or |
45 | default lock count is 1, which means it is unlocked by default. Zero (or |
… | |
… | |
136 | =cut |
136 | =cut |
137 | |
137 | |
138 | sub guard { |
138 | sub guard { |
139 | &down; |
139 | &down; |
140 | # double indirection because bless works on the referenced |
140 | # double indirection because bless works on the referenced |
141 | # object, not (only) on the reference itself. |
141 | # object, not (just) on the reference itself. |
142 | bless \\$_[0], Coro::Semaphore::guard::; |
142 | bless \\$_[0], Coro::Semaphore::guard::; |
143 | } |
143 | } |
144 | |
144 | |
145 | #=item $guard = $sem->timed_guard ($timeout) |
145 | #=item $guard = $sem->timed_guard ($timeout) |
146 | # |
146 | # |