ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/bin/aemp
(Generate patch)

Comparing AnyEvent-MP/bin/aemp (file contents):
Revision 1.51 by root, Fri Mar 2 19:19:21 2012 UTC vs.
Revision 1.52 by root, Fri Mar 2 19:48:18 2012 UTC

655\=name switch to another node 655\=name switch to another node
656package P switch to package P when evaluating 656package P switch to package P when evaluating
657\$ECHO contains the name of a port that echos everything sent to it 657\$ECHO contains the name of a port that echos everything sent to it
658 658
659EOF 659EOF
660 print "$node> "; 660 my $pkg = "AnyEvent::MP::Kernel";
661 my $pkg;
662 my $cv = AE::cv; 661 my $cv = AE::cv;
663 my $echo = port { 662 my $echo = port {
664 print "\n ECHO<$AnyEvent::MP::Kernel::SRCNODE->{id}> ", JSON::XS::encode_json \@_, "\n$node> "; 663 print "\n ECHO<$AnyEvent::MP::Kernel::SRCNODE->{id}> ", JSON::XS::encode_json \@_, "\n$node $pkg> ";
665 }; 664 };
665 print "$node $pkg> ";
666 my $t = AE::io *STDIN, 0, sub { 666 my $t = AE::io *STDIN, 0, sub {
667 chomp (my $line = <STDIN>); 667 chomp (my $line = <STDIN>);
668 668
669 if ($line =~ s/^=//) { 669 if ($line =~ s/^=//) {
670 if (length $line) { 670 if (length $line) {
671 $node = $line; 671 $node = $line;
672 } else { 672 } else {
673 print +(join " ", AnyEvent::MP::Kernel::up_nodes), "\n"; 673 print +(join " ", AnyEvent::MP::Kernel::up_nodes), "\n";
674 } 674 }
675 } elsif ($line =~ /^\s*package\s+(\S+)\s*;?\s*$/) { 675 } elsif ($line =~ /^\s*package\s+(\S+)\s*;?\s*$/) {
676 $pkg = "package $1"; 676 $pkg = $1;
677 } elsif ($line =~ /\S/) { 677 } elsif ($line =~ /\S/) {
678 my $time = AE::time; 678 my $time = AE::time;
679 AnyEvent::MP::Kernel::eval_on $node, "$pkg; my \$ECHO = '$echo'; $line", port { 679 AnyEvent::MP::Kernel::eval_on
680 $node,
681 "package $pkg; my \$ECHO = '$echo'; $line",
682 port {
683 kil $SELF;
684
680 my ($err, @res) = @_; 685 my ($err, @res) = @_;
681 686
682 $time = AE::time - $time; 687 $time = AE::time - $time;
683 688
684 print "\n $node: $line\n"; 689 print "\n $node: $line\n";
685 if (length $err) { 690 if (length $err) {
686 print " $err @res"; 691 print " $err @res";
687 } else { 692 } else {
688 print " ", JSON::XS::encode_json \@res; 693 print " ", JSON::XS::encode_json \@res;
694 }
695 printf "\n %0.3fs\n", $time;
696 print "$node $pkg> ";
689 } 697 }
690 printf "\n %0.3fs\n", $time;
691 print "$node> ";
692 }; 698 ;
693 } 699 }
694 700
695 print "$node> "; 701 print "$node $pkg> ";
696 }; 702 };
697 $cv->recv; 703 $cv->recv;
698} 704}
699 705
700sub node_eval { 706sub node_eval {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines