ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Semaphore.pm
(Generate patch)

Comparing Coro/Coro/Semaphore.pm (file contents):
Revision 1.105 by root, Wed Apr 14 01:56:03 2010 UTC vs.
Revision 1.112 by root, Sat Feb 19 06:51:23 2011 UTC

2 2
3Coro::Semaphore - counting semaphores 3Coro::Semaphore - counting semaphores
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use Coro::Semaphore; 7 use Coro;
8 8
9 $sig = new Coro::Semaphore [initial value]; 9 $sig = new Coro::Semaphore [initial value];
10 10
11 $sig->down; # wait for signal 11 $sig->down; # wait for signal
12 12
25Counting semaphores are typically used to coordinate access to 25Counting semaphores are typically used to coordinate access to
26resources, with the semaphore count initialized to the number of free 26resources, with the semaphore count initialized to the number of free
27resources. Threads then increment the count when resources are added 27resources. Threads then increment the count when resources are added
28and decrement the count when resources are removed. 28and decrement the count when resources are removed.
29 29
30You don't have to load C<Coro::Semaphore> manually, it will be loaded
31automatically when you C<use Coro> and call the C<new> constructor.
32
30=over 4 33=over 4
31 34
32=cut 35=cut
33 36
34package Coro::Semaphore; 37package Coro::Semaphore;
35 38
36use common::sense; 39use common::sense;
37 40
38use Coro (); 41use Coro ();
39 42
40our $VERSION = 5.22; 43our $VERSION = 5.37;
41 44
42=item new [inital count] 45=item new [inital count]
43 46
44Creates a new sempahore object with the given initial lock count. The 47Creates a new sempahore object with the given initial lock count. The
45default lock count is 1, which means it is unlocked by default. Zero (or 48default lock count is 1, which means it is unlocked by default. Zero (or

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines