… | |
… | |
35 | |
35 | |
36 | no warnings qw(uninitialized); |
36 | no warnings qw(uninitialized); |
37 | |
37 | |
38 | use Coro (); |
38 | use Coro (); |
39 | |
39 | |
40 | $VERSION = 0.52; |
40 | $VERSION = 0.53; |
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 |
… | |
… | |
78 | |
78 | |
79 | while ($_[0][0] <= 0) { |
79 | while ($_[0][0] <= 0) { |
80 | push @{$_[0][1]}, $Coro::current; |
80 | push @{$_[0][1]}, $Coro::current; |
81 | Coro::schedule; |
81 | Coro::schedule; |
82 | if ($timeout) { |
82 | if ($timeout) { |
83 | # ugly as hell. slow, too! |
83 | # ugly as hell. slow, too, btw! |
84 | for (0..$#{$_[0][1]}) { |
84 | for (0..$#{$_[0][1]}) { |
85 | if ($_[0][1][$_] == $Coro::current) { |
85 | if ($_[0][1][$_] == $Coro::current) { |
86 | splice @{$_[0][1]}, $_, 1; |
86 | splice @{$_[0][1]}, $_, 1; |
87 | return; |
87 | return; |
88 | } |
88 | } |