Any reason why select() uses only level-triggered notification mode?
Alan Bateman
Alan.Bateman at Sun.COM
Mon Dec 22 05:31:22 PST 2008
Misha Dmitriev (Миша) wrote:
> Hi nio-dev,
>
> I've just recently started to work with NIO, and soon discovered that
> Selector.select(), when it uses Unix epoll() call, is hardcoded to use
> it in level-triggered mode only. This creates a difficulty if for
> better parallelization I want to call select() in one thread, but
> handle the received event in other thread, while the first thread
> calls select() again. In that case, if additional measures aren't
> taken, select() will keep returning the same event for the same
> channel until it's actually processed. If select() called epoll in
> edge-triggered mode, that won't happen.
>
> I wonder if there are any fundamental reasons for not giving an option
> to use edge-triggered mode in Selector.select(). Or, if there are no
> such reasons, if there is any chance that this will be implemented in
> some future JDK version.
>
>
>
Hey Misha, I still have some questions about hotswap for you :-)
The Selector API requires a level-triggered polling mechanism.
Edge-triggered interfaces require a much tighter coupling with the I/O
methods. A paper from a group in University of Waterloo [1] touched on
this topic and may be useful.
I'm curious to know if you have tried different strategies for hand-off?
For example, using interestOps to set the interest set to 0 while you
process the events in the other thread for example.
-Alan.
[1] http://www.cs.uwaterloo.ca/~brecht/papers/getpaper.php?file=ols-2004.pdf
More information about the nio-dev
mailing list