… | |
… | |
15 | $sig->up; |
15 | $sig->up; |
16 | |
16 | |
17 | =head1 DESCRIPTION |
17 | =head1 DESCRIPTION |
18 | |
18 | |
19 | This module implements counting semaphores. You can initialize a mutex |
19 | This module implements counting semaphores. You can initialize a mutex |
20 | with any level of parallel users, that is, you can intialize a sempahore |
20 | with any level of parallel users, that is, you can initialize a sempahore |
21 | that can be C<down>ed more than once until it blocks. There is no owner |
21 | that can be C<down>ed more than once until it blocks. There is no owner |
22 | associated with semaphores, so one thread can C<down> it while another can |
22 | associated with semaphores, so one thread can C<down> it while another can |
23 | C<up> it (or vice versa), C<up> can be called before C<down> and so on: |
23 | C<up> it (or vice versa), C<up> can be called before C<down> and so on: |
24 | the semaphore is really just an integer counter that optionally blocks |
24 | the semaphore is really just an integer counter that optionally blocks |
25 | when it is 0. |
25 | when it is 0. |
… | |
… | |
42 | |
42 | |
43 | use Coro (); |
43 | use Coro (); |
44 | |
44 | |
45 | our $VERSION = 6.511; |
45 | our $VERSION = 6.511; |
46 | |
46 | |
47 | =item new [inital count] |
47 | =item new [initial count] |
48 | |
48 | |
49 | Creates a new sempahore object with the given initial lock count. The |
49 | Creates a new sempahore object with the given initial lock count. The |
50 | default lock count is 1, which means it is unlocked by default. Zero (or |
50 | default lock count is 1, which means it is unlocked by default. Zero (or |
51 | negative values) are also allowed, in which case the semaphore is locked |
51 | negative values) are also allowed, in which case the semaphore is locked |
52 | by default. |
52 | by default. |