From: Matt S Trout Date: Tue, 19 Mar 2013 18:58:21 +0000 (+0000) Subject: switch from CPS::Future to Future X-Git-Tag: v0.003002~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=783105c4013747147c7195f043961af40b9908b7;p=scpubgit%2FObject-Remote.git switch from CPS::Future to Future --- diff --git a/Makefile.PL b/Makefile.PL index 4e934be..2cdb3e3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -11,7 +11,8 @@ WriteMakefile( Moo => 0, 'Module::Runtime' => 0, 'JSON::PP' => 0, - 'CPS::Future' => 0, + 'Future' => 0.10, + 'MRO::Compat' => 0, # required to fatpack Moo 'Class::C3' => 0, # required to fatpack Moo 'String::ShellQuote' => 0, # required for ssh argument manipulation 'Log::Contextual' => 0.005000 diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 349d2a1..d64a8dd 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -15,8 +15,9 @@ use POSIX ":sys_wait_h"; use Module::Runtime qw(use_module); use Scalar::Util qw(weaken blessed refaddr openhandle); use JSON::PP qw(encode_json); -use Moo; +use Future; use Carp qw(croak); +use Moo; BEGIN { router()->exclude_forwarding } @@ -58,7 +59,7 @@ has read_channel => ( ); has on_close => ( - is => 'rw', default => sub { $_[0]->_install_future_handlers(CPS::Future->new) }, + is => 'rw', default => sub { $_[0]->_install_future_handlers(Future->new) }, trigger => sub { log_trace { "Installing handlers into future via trigger" }; $_[0]->_install_future_handlers($_[1]) @@ -324,7 +325,7 @@ sub send_free { sub send { my ($self, $type, @call) = @_; - my $future = CPS::Future->new; + my $future = Future->new; my $remote = $self->remote_objects_by_id->{$call[0]}; unshift @call, $type => $self->_local_object_to_id($future); diff --git a/lib/Object/Remote/ConnectionServer.pm b/lib/Object/Remote/ConnectionServer.pm index da4a4d3..352d329 100644 --- a/lib/Object/Remote/ConnectionServer.pm +++ b/lib/Object/Remote/ConnectionServer.pm @@ -4,6 +4,7 @@ use Scalar::Util qw(blessed weaken); use Module::Runtime qw(use_module); use Object::Remote; use Object::Remote::Logging qw( :log :dlog ); +use Future; use IO::Socket::UNIX; use Moo; @@ -53,7 +54,7 @@ sub _listen_ready { my $new = $fh->accept or die "Couldn't accept: $!"; log_trace { "Setting file handle non-blocking" }; $new->blocking(0); - my $f = CPS::Future->new; + my $f = Future->new; log_trace { "Creating a new connection with the remote node" }; my $c = use_module('Object::Remote::Connection')->new( receive_from_fh => $new, diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm index 45332d5..1b7c659 100644 --- a/lib/Object/Remote/FatNode.pm +++ b/lib/Object/Remote/FatNode.pm @@ -25,7 +25,7 @@ my $command = qq( $extra_libs -mObject::Remote -mObject::Remote::Connector::STDIO - -mCPS::Future + -mFuture -mMRO::Compat -mClass::C3 -mClass::C3::next diff --git a/lib/Object/Remote/Future.pm b/lib/Object/Remote/Future.pm index d5d528a..d8acd3c 100644 --- a/lib/Object/Remote/Future.pm +++ b/lib/Object/Remote/Future.pm @@ -8,12 +8,12 @@ use Object::Remote::Logging qw( :log router ); BEGIN { router()->exclude_forwarding } -use CPS::Future; +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); } @@ -48,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, @_; } @@ -61,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; } @@ -101,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) = @_; diff --git a/lib/Object/Remote/Node.pm b/lib/Object/Remote/Node.pm index f11c406..dd7b85f 100644 --- a/lib/Object/Remote/Node.pm +++ b/lib/Object/Remote/Node.pm @@ -5,7 +5,6 @@ use Object::Remote::Connector::STDIO; use Object::Remote::Logging qw(:log :dlog); use Object::Remote::WatchDog; use Object::Remote; -use CPS::Future; sub run { my ($class, %args) = @_; diff --git a/lib/Object/Remote/ReadChannel.pm b/lib/Object/Remote/ReadChannel.pm index f812e3f..d2008db 100644 --- a/lib/Object/Remote/ReadChannel.pm +++ b/lib/Object/Remote/ReadChannel.pm @@ -1,6 +1,5 @@ package Object::Remote::ReadChannel; -use CPS::Future; use Scalar::Util qw(weaken openhandle); use Object::Remote::Logging qw(:log :dlog router ); use Moo;