Created
December 9, 2015 20:32
-
-
Save akahan/6074293ac532f1cc6b80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Master | |
my $slave_handle; | |
$slave_handle = AnyEvent::Handle->new( | |
fh => $slave->{_socket}, | |
on_read => sub { | |
shift->push_read( json => sub { | |
my ( $h, $job_result ) = @_; | |
$jc->job_done( $job_id, $job_result ); | |
}); | |
} | |
); | |
# Поставим задачу | |
$slave_handle->push_write($job_mod."\n"); | |
# Slave | |
$self->{_cv} = AnyEvent->condvar; | |
my $master_handle; | |
$master_handle = AnyEvent::Handle->new( | |
fh => $self->{_socket}, | |
on_read => sub { | |
shift->push_read( line => sub { | |
my ( $h, $job_mod ) = @_; | |
debug "Slave $self->{_id} got $job_mod"; | |
load_class($job_mod); | |
my $result = $job_mod->execute(); | |
$h->push_write( json => $result ); | |
}); | |
} | |
); | |
$self->cv->recv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[debug] [09.12.2015 16:55:19] [13609] Slave choosed: 1
[debug] [09.12.2015 16:55:19] [13610] Slave 1 got AsyncJobsServer::Job::MemInfo
[debug] [09.12.2015 16:55:20] [13609] Requested command: job