You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Todor Boev <t_...@prosyst.bg> on 2007/05/08 12:21:35 UTC

Why not ReadFuture?

Hello all,
My question is why is the reading style from an IoSession different from 
the writing style? The obvious way seems to be:

interface IoSession {
    ....  
    ReadFuture read();
    WriteFuture write(Object message);
    ....
}

Where:

interface ReadFuture extends IoFuture {
    Object getMessage();
}

So when I want to read I do:

session.read().addListener(<some handler>);

This is wonderfully symmetric to:

session.write(<the message>).addListener(<some handler>);

In this way the Proactor I/O style is maintained for all I/O rather than 
just for accept, connect, close and write with read being somewhat 
different.
I take it it was a deliberate choice to use a different style for the 
reading and I'm curious what drove your design. I scanned the mailing 
list for a similar question but did not find any (forgive me if I missed 
it).

Cheers,
Todor Boev

Re: Why not ReadFuture?

Posted by Niklas Therning <ni...@trillian.se>.
This has been discussed quite recently:

http://www.nabble.com/forum/ViewPost.jtp?post=9957679&framed=y

It would certainly be a nice feature.

/Niklas

Todor Boev wrote:
> Hello all,
> My question is why is the reading style from an IoSession different
> from the writing style? The obvious way seems to be:
>
> interface IoSession {
>    ....     ReadFuture read();
>    WriteFuture write(Object message);
>    ....
> }
>
> Where:
>
> interface ReadFuture extends IoFuture {
>    Object getMessage();
> }
>
> So when I want to read I do:
>
> session.read().addListener(<some handler>);
>
> This is wonderfully symmetric to:
>
> session.write(<the message>).addListener(<some handler>);
>
> In this way the Proactor I/O style is maintained for all I/O rather
> than just for accept, connect, close and write with read being
> somewhat different.
> I take it it was a deliberate choice to use a different style for the
> reading and I'm curious what drove your design. I scanned the mailing
> list for a similar question but did not find any (forgive me if I
> missed it).
>
> Cheers,
> Todor Boev


-- 
Niklas Therning
www.spamdrain.net