Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/coro-countdown
A counter that signals when it reaches 0 for coro and perl
https://github.com/sysread/coro-countdown
Last synced: about 1 month ago
JSON representation
A counter that signals when it reaches 0 for coro and perl
- Host: GitHub
- URL: https://github.com/sysread/coro-countdown
- Owner: sysread
- Created: 2017-11-08T20:52:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-08T21:30:54.000Z (about 7 years ago)
- Last Synced: 2023-08-20T22:28:49.872Z (over 1 year ago)
- Language: Perl
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
Coro::Countdown - a counter that signals when it reaches 0
=head1 VERSION
version 0.02
=head1 SYNOPSIS
use Coro;
use Coro::Countdown;my $counter = Coro::Countdown->new;
$counter->up;
async { $counter->down };# Block until $counter->down is called
$counter->join;=head1 DESCRIPTION
Oftentimes it is necessary to wait until all users of a resource have completed
before a program may continue. Examples of this include a pool of pending
network requests, etc. A countdown signal will broadcast to any waiters once
all "checked out" resources have been "returned".=head1 METHODS
=head2 new
Optionally takes an initial value, defaulting to 0.
=head2 join
Cedes until the count decrements to 0. If the counter is already at 0, returns
immediately.=head2 count
Returns the current counter value.
=head2 up
Increments the counter value ("checks out" a resource).
=head2 down
Decrements the counter value ("returns" the resource). If the counter reaches
0, all watchers are signaled and the counter resets. It is then ready to be
reused.=head1 AUTHOR
Jeff Ober
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Jeff Ober.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.=cut