James Im wrote:
IoSession session = ...;
WriteFuture future = session.write(...);
// Wait until the message is completely written out to the O/S buffer.
future.join();

I was looking at this code and I got an idea.

As we want mina to be as non blocking as possible may be instead of
having the thread waiting it could use continuation like some web
frameworks.

I imagine that continuation are like a wait operation without blocking
the thread.

I don't know how continuation are implemented nor what the cost is to do
a 'continuation' but I thought that might be useful when you want your
code to execute in a synchronous manner(waiting for something to happen
before continuing).

Adding an IoFutureListener to your WriteFuture will accomplish roughly what you are suggesting:

session.write(...).addListener(new IoFutureListener() {
    public void operationComplete(IoFuture f) {
        WriteFuture future = (WriteFuture ) f;
        if (future.isWritten()) {
            // Message has been written successfully
        } else {
            // Message couldn't be written
        }
    }
});

HTH
/Niklas

Reply via email to