mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 이희승 "(Trustin Lee)" <trus...@gmail.com>
Subject Re: Question About WriteFuture and Multiple Threads
Date Wed, 20 Feb 2008 02:56:53 GMT
Hi Geoff,

There's no direct relationship in the order of events between
IoFutureListener and IoHandler, that is, they are designed to be
independent from each other in event order.


2008-02-14 (목), 10:41 -0700, Geoff Cadien 쓰시길:
> I'm experiencing different behavior when calling IoSession.write() and then
> adding an IoFutureListener to the returned WriteFuture depending on the
> thread from which the IoSession.write is called.  Example:
> WriteFuture future = session.write(someMessage);
> future.addListener(someListener);
> Now if that snippet of code is executed from the IoProcessor thread I see
> the IoFutureListener.operationComplete called followed by
> IoHandler.messageSent called.
> If the above snippet is called from a different there seems to be a race.
> Sometimes IoFutureListener.operationComplete is called followed by
> IoHandler.messageSent and sometimes the other way around.  What seems to be
> happening is that when IoSession.write is called (from a non IoProcessor
> thread) IoFilterChain.filterWrite is fired, the message is added to the
> IoSession writeRequestQueue, and the IoProcessor writes the message and
> fires messageSent before the IoFutureListener is added to the WriteFuture.
> So my question is is this the expected behavior or is it a bug?
> -geoff
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
what we call human nature is actually human habit

View raw message