… | |
… | |
137 | |
137 | |
138 | sub guard { |
138 | sub guard { |
139 | &down; |
139 | &down; |
140 | # double indirection because bless works on the referenced |
140 | # double indirection because bless works on the referenced |
141 | # object, not (just) on the reference itself. |
141 | # object, not (just) on the reference itself. |
142 | bless \\$_[0], Coro::Semaphore::guard::; |
142 | bless [$_[0]], Coro::Semaphore::guard:: |
143 | } |
143 | } |
144 | |
144 | |
145 | #=item $guard = $sem->timed_guard ($timeout) |
145 | #=item $guard = $sem->timed_guard ($timeout) |
146 | # |
146 | # |
147 | #Like C<guard>, but returns undef if semaphore couldn't be acquired within |
147 | #Like C<guard>, but returns undef if semaphore couldn't be acquired within |
… | |
… | |
152 | # ? bless \\$_[0], Coro::Semaphore::guard:: |
152 | # ? bless \\$_[0], Coro::Semaphore::guard:: |
153 | # : (); |
153 | # : (); |
154 | #} |
154 | #} |
155 | |
155 | |
156 | sub Coro::Semaphore::guard::DESTROY { |
156 | sub Coro::Semaphore::guard::DESTROY { |
157 | &up(${${$_[0]}}); |
157 | &up($_[0][0]); |
158 | } |
158 | } |
159 | |
159 | |
160 | =back |
160 | =back |
161 | |
161 | |
162 | =head1 AUTHOR |
162 | =head1 AUTHOR |