NAME
AnyEvent::Semaphore - AnyEvent based semaphores
SYNOPSIS
use AnyEvent::Semaphore;
my $s = AnyEvent::Semaphore->new;
$s->down;
# Do something fun
$s->up;
DESCRIPTION
This module is an AnyEvent based implementation of counting semaphores and is very similar to Coro::Semaphore in the way it works.
It implements the following methods
- new ($count?)
-
Creates the semaphore, with the $count argument being optional. If a $count is specified, this is the number of slots the semaphore will have. If not specified, it defaults to 1.
- down
-
Decreases the semaphore count by one. If the count is zero, this will cause the method to block until a slot opens up in the semaphore.
- up
-
Increases the semaphore count by one. If the slot count was zero, this will wake up one blocker that was waiting for the semaphore.
- count
-
Returns the current semaphore count.
- guard
-
Calling this method will down the semaphore (And will obviously block if neccesary) and return a guard object. If this guard object is in some way destroyed, the semaphore is upped.
ACKNOWLEDGEMENTS
- Marc Lehmann for writing AnyEvent.
SEE ALSO
BUGS
Most software has bugs. This module probably isn't an exception. If you find a bug please either email me, or add the bug to cpan-RT.
AUTHOR
Anders Nor Berle <berle@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2008 by Anders Nor Berle.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.