NAME
Broker::Async::Worker
DESCRIPTION
Used by Broker::Async for tracking the state of asynchronous work.
ATTRIBUTES
code
The code reference used to start the work. This will be invoked with the arguments passed to do
.
Must return a Future subclass.
concurrency
The number of concurrent tasks a worker can execute. Do'ing more tasks than this limit is a fatal error.
Defaults to 1.
METHODS
new
my $worker = Broker::Async::Worker->new(
code => sub { ... },
concurrency => $max,
);
available
Indicates whether the worker is available to do
tasks. It is a fatal error to invoke do
when this is false.
do
my $future = $worker->do($task);
Invokes the code attribute with the given arguments. Returns a future that will be resolved when the work is done.
AUTHOR
Mark Flickinger <maf@cpan.org>
LICENSE
This software is licensed under the same terms as Perl itself.