use CPS::Future;
-our @EXPORT = qw(future await_future);
+our @EXPORT = qw(future await_future await_all);
sub future (&) {
my $f = $_[0]->(CPS::Future->new);
return wantarray ? $f->get : ($f->get)[0];
}
+sub await_all {
+ await_future(CPS::Future->needs_all(@_));
+ map $_->get, @_;
+}
+
package start;
sub AUTOLOAD {
my $invocant = shift;
- my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
+ my ($method) = our $AUTOLOAD =~ /^start::(.+)$/;
if (ref($invocant) eq 'ARRAY') {
return [ map $_->${\"start::${method}"}, @$invocant ];
}
return $res;
}
-package await;
+1;
-sub AUTOLOAD {
- my $invocant = shift;
- my ($method) = our $AUTOLOAD =~ /([^:]+)$/;
- my @invocants = (ref($invocant) eq 'ARRAY' ? @$invocant : $invocant);
- my @futures = map $_->${\"start::${method}"}, @$invocant;
- Object::Remote::Future::await_future(CPS::Future->needs_all(@futures));
- return map $_->get, @futures;
-}
+=head1 NAME
-1;
+Object::Remote::Future - Asynchronous calling for L<Object::Remote>
+
+=head1 LAME
+
+Shipping prioritised over writing this part up. Blame mst.
+
+=cut