X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FFuture.pm;h=d8acd3c7c989efb0dfe51f2b54ed1124acf5c5af;hp=2817539c7a8c3cc5909a04830461c1d5f779eabd;hb=783105c4013747147c7195f043961af40b9908b7;hpb=9031635d18e754da303557b656c63ce8e7eb8e77 diff --git a/lib/Object/Remote/Future.pm b/lib/Object/Remote/Future.pm index 2817539..d8acd3c 100644 --- a/lib/Object/Remote/Future.pm +++ b/lib/Object/Remote/Future.pm @@ -4,14 +4,16 @@ use strict; use warnings; use base qw(Exporter); -use Object::Remote::Logging qw( :log Dlog_trace ); +use Object::Remote::Logging qw( :log router ); -use CPS::Future; +BEGIN { router()->exclude_forwarding } + +use Future; our @EXPORT = qw(future await_future await_all); sub future (&;$) { - my $f = $_[0]->(CPS::Future->new); + my $f = $_[0]->(Future->new); return $f if ((caller(1+($_[1]||0))||'') eq 'start'); await_future($f); } @@ -29,15 +31,15 @@ sub await_future { $f->on_ready(sub { log_trace { my $l = @await; "future has become ready, length of \@await: '$l'" }; if ($f == $await[-1]) { - log_debug { "This future is not waiting on anything so calling stop on the run loop" }; - $loop->stop; + log_trace { "This future is not waiting on anything so calling stop on the run loop" }; + $loop->stop; } }); - log_debug { "Starting run loop for newly created future" }; + log_trace { "Starting run loop for newly created future" }; $loop->run; } if (@await and $await[-1]->is_ready) { - log_debug { "Last future in await list was ready, stopping run loop" }; + log_trace { "Last future in await list was ready, stopping run loop" }; $loop->stop; } log_trace { "await_future() returning" }; @@ -46,7 +48,7 @@ sub await_future { sub await_all { log_trace { my $l = @_; "await_all() invoked with '$l' futures to wait on" }; - await_future(CPS::Future->wait_all(@_)); + await_future(Future->wait_all(@_)); map $_->get, @_; } @@ -59,12 +61,12 @@ sub AUTOLOAD { my ($method) = our $AUTOLOAD =~ /^start::(.+)$/; my $res; unless (eval { $res = $invocant->$method(@_); 1 }) { - my $f = CPS::Future->new; + my $f = Future->new; $f->fail($@); return $f; } - unless (Scalar::Util::blessed($res) and $res->isa('CPS::Future')) { - my $f = CPS::Future->new; + unless (Scalar::Util::blessed($res) and $res->isa('Future')) { + my $f = Future->new; $f->done($res); return $f; } @@ -99,7 +101,7 @@ sub AUTOLOAD { my @args = @_; # Need two copies since if we're called on an already complete future # $f will be freed immediately - my $ret = my $f = CPS::Future->new; + my $ret = my $f = Future->new; $invocant->on_fail(sub { $f->fail(@_); undef($f); }); $invocant->on_done(sub { my ($obj) = @_;