RapidApp::BgTask::MsgPipeNB
sub runServer { my $self= shift; my $pipe= RapidApp::BgTask::MsgPipeNB->new( socket => $sock, autoRMI => 1, rmiTargetObj => $self ); my $exit= AE::cv; $pipe->onMessage( sub { my ($pipe, $msg)= @_; return $exit->send if $msg->{exit}; $msg->{got_it}= 1; $pipe->pushMessage($msg); } ); $exit->recv; }
This is a version of MsgPipe that can work with non-blocking event-driven IO.
Instead of recvMessage, use a callback handler in onMessage.
Instead of sendMessage, use pushMessage.
Instead of callRemoteMethod, use pushMethodCall.
Adds a message to the queue.
Note that there is no guarantee that the message actually got sent by the copletion of this call.
Push a method call onto the send queue, and register a callback which will run when a response (either success or failure) is received.
Note that the third parameter (timeout) is not yet supported.
On success, the callback will be called as callback( $msgPipe, 1, \@result )
On failure, the callback will be called as callback( $msgPipe, 0, $errMsg )
To install RapidApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RapidApp
CPAN shell
perl -MCPAN -e shell install RapidApp
For more information on module installation, please visit the detailed CPAN module installation guide.