… | |
… | |
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 intialize 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 |
22 | associated with semaphores, so one thread can C<down> it while another can |
23 | can C<up> it. |
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 |
|
|
25 | when it is 0. |
24 | |
26 | |
25 | Counting semaphores are typically used to coordinate access to |
27 | Counting semaphores are typically used to coordinate access to |
26 | resources, with the semaphore count initialized to the number of free |
28 | resources, with the semaphore count initialized to the number of free |
27 | resources. Threads then increment the count when resources are added |
29 | resources. Threads then increment the count when resources are added |
28 | and decrement the count when resources are removed. |
30 | and decrement the count when resources are removed. |
29 | |
31 | |
30 | You don't have to load C<Coro::Semaphore> manually, it will be loaded |
32 | You don't have to load C<Coro::Semaphore> manually, it will be loaded |
31 | automatically when you C<use Coro> and call the C<new> constructor. |
33 | automatically when you C<use Coro> and call the C<new> constructor. |
32 | |
34 | |
33 | =over 4 |
35 | =over 4 |
34 | |
36 | |
35 | =cut |
37 | =cut |
36 | |
38 | |