AnyEvent-FIFO
view release on metacpan or search on metacpan
# NAME
AnyEvent::FIFO - Simple FIFO Callback Dispatch
# SYNOPSIS
my $fifo = AnyEvent::FIFO->new(
max_active => 1, # max "concurrent" callbacks to execute per slot
);
# send to the "default" slot
$fifo->push( \&callback, @args );
# send to the "slot" slot
$fifo->push( "slot", \&callback, @args );
# dispatch is done automatically
# wait for all tasks to complete
my ($guard, @args) = @_;
# next callback will be executed when $guard is undef'ed or
# when it goes out of scope
}
# DESCRIPTION
AnyEvent::FIFO is a simple FIFO queue to dispatch events in order.
If you use regular watchers and register callbacks from various places in
your program, you're not necessarily guaranteed that the callbacks will be
executed in the order that you expect. By using this module, you can
register callbacks and they will be executed in that particular order.
# METHODS
## new
- max\_active => $number
Number of concurrent callbacks to be executed __per slot__.
- cv => $cv
Instance of [AnyEvent condvar](http://search.cpan.org/perldoc?AnyEvent#CONDITION VARIABLES). AnyEvent::FIFO will create one for you if this is not provided.
AnyEvent::FIFO calls $cv->begin() when new task is pushed and $cv->end() when task is completed.
## push (\[$slot,\] $cb \[,@args\])
- $slot
lib/AnyEvent/FIFO.pm view on Meta::CPAN
__END__
=head1 NAME
AnyEvent::FIFO - Simple FIFO Callback Dispatch
=head1 SYNOPSIS
my $fifo = AnyEvent::FIFO->new(
max_active => 1, # max "concurrent" callbacks to execute per slot
);
# send to the "default" slot
$fifo->push( \&callback, @args );
# send to the "slot" slot
$fifo->push( "slot", \&callback, @args );
# dispatch is done automatically
# wait for all tasks to complete
lib/AnyEvent/FIFO.pm view on Meta::CPAN
my ($guard, @args) = @_;
# next callback will be executed when $guard is undef'ed or
# when it goes out of scope
}
=head1 DESCRIPTION
AnyEvent::FIFO is a simple FIFO queue to dispatch events in order.
If you use regular watchers and register callbacks from various places in
your program, you're not necessarily guaranteed that the callbacks will be
executed in the order that you expect. By using this module, you can
register callbacks and they will be executed in that particular order.
=head1 METHODS
=head2 new
=over 4
=item max_active => $number
Number of concurrent callbacks to be executed B<per slot>.
=item cv => $cv
Instance of L<AnyEvent condvar|AnyEvent/"CONDITION VARIABLES">. AnyEvent::FIFO will create one for you if this is not provided.
AnyEvent::FIFO calls $cv->begin() when new task is pushed and $cv->end() when task is completed.
=back
=head2 push ([$slot,] $cb [,@args])
( run in 1.625 second using v1.01-cache-2.11-cpan-d6f9594c0a5 )