NAME
Argon::Simple
SYNOPSIS
use Argon::Simple;
connect 'somehost:9999';
my $deferred = process { $_[0] * 2 } 21;
if ($deferred->() == 42) {
print "So long, and thanks for all the fish!\n";
}
my ($deferred, $is_finished) = process { $_[0] * 2 } 21;
do { print "." } until $is_finished->();
print "So long, and thanks for all the fish!\n";
DESCRIPTION
In most cases, a script or application is going to connect to a single Argon system. For these cases, this module provides simplified access to the Argon system.
SUBROUTINES
connect("host:port")
Connects to a single Argon manager. If called with a single argument, a string in the form of "host:port" is expected. Alternately, the host and port may be passed as two separate arguments (e.g. connect($host, $port)
).
process { code } @args
When called in scalar context, returns a CODE reference. When called, the Coro
thread will block (cede) until the result is retrieved from the Argon system and is available.
When called in list context, additionally returns a CODE reference which evaluates to true when the task has been completed by the Argon system.
See also "A NOTE ABOUT IMPORTS AND CLOSURES" in Coro::ProcessPool, which has some important information about use
and require
.
task 'Task::Class', @args
Similar to process, but passes in the name of a class implementing the methods new(@args)
and run
. The result of run
is returned. Note that the class must be found on the workers' include paths.
AUTHOR
Jeff Ober <jeffober@gmail.com>