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.1 by root, Tue Jul 3 03:48:36 2001 UTC vs.
Revision 1.2 by root, Tue Jul 3 03:52:48 2001 UTC

25use Coro::Process (); 25use Coro::Process ();
26 26
27$VERSION = 0.01; 27$VERSION = 0.01;
28 28
29sub new { 29sub new {
30 bless [$_[1]], $_[0]; 30 bless [defined $_[1] ? $_[1] : 1], $_[0];
31} 31}
32 32
33sub down { 33sub down {
34 my $self = shift; 34 my $self = shift;
35 while ($self->[0] <= 0) { 35 while ($self->[0] <= 0) {
39 --$self->[0]; 39 --$self->[0];
40} 40}
41 41
42sub up { 42sub up {
43 my $self = shift; 43 my $self = shift;
44 if (++@{$self->[1]} == 0) { 44 if (++$self->[0] > 0) {
45 (shift @{$self->[1]})->ready if @{$self->[1]}; 45 (shift @{$self->[1]})->ready if @{$self->[1]};
46 } 46 }
47} 47}
48 48
49sub try { 49sub try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines