The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RapidApp::BgTask::MsgPipeNB

SYNOPSIS

  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;
  }

DESCRIPTION

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.

pushMessage( \%message )

Adds a message to the queue.

Note that there is no guarantee that the message actually got sent by the copletion of this call.

pushMethodCall( methodName => \@params, $unsupported_timeout, $callback )

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 )