[zeromq-dev] Reactive proactor zmq_engine_t?

Steven McCoy steven.mccoy at miru.hk
Sat Jun 11 20:47:38 CEST 2011


I'm looking at Windows named pipe support with IOCP and have most
implemented but it appears it would be better to investigate turning around
core component before bolting things above.

The current *zmq_engine_t *implementation is as a reactor, an incoming event
will retrieve a buffer then populate it with data from the underlying
socket, similarly outgoing events get the data and advance.  A reactive
proactor would turn things around to prepare for a full proactor model and
will presumably add some overhead which the quantification of would be
interesting.

So an incoming event is to be interpreted as an incoming completion event:

*present reactor:*

void zmq::zmq_engine_t::in_event ()
{
        //  Retrieve the buffer and read as much data as possible.
        decoder.get_buffer (&inpos, &insize);
        insize = tcp_socket.read (inpos, insize);

    //  Push the data to the decoder.
    size_t processed = decoder.process_buffer (inpos, insize);
...
}

*proactor equivalent for one pending operation:*

void zmq::zmq_engine_t::in_event ()
{
    //  Data is now available to process.
    size_t processed = decoder.process_buffer (inpos, insize);

    //  Retrieve buffer for next IO operation.
    decoder.get_buffer (&inpos, &insize);
    //  Size is not known until IO has completed.
    tcp_socket.async_read (inpos, insize);
...
}

*reactive proactor version:*

void zmq::zmq_engine_t::in_event ()
{
    //  Read data into buffer.
    insize = tcp_socket.read (inpos, insize);

    //  Data is now available to process.
    size_t processed = decoder.process_buffer (inpos, insize);

    //  Retrieve buffer for next IO operation.
    decoder.get_buffer (&inpos, &insize);
...
}

Confusing everyone yet?

-- 
Steve-o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110611/001f2b98/attachment.htm>


More information about the zeromq-dev mailing list