Callback Based Selectors
David M. Lloyd
david.lloyd at redhat.com
Mon Jan 18 16:00:42 UTC 2016
On 01/16/2016 05:14 AM, Richard Warburton wrote:
> Hi gents,
>
> I've prototyped a callback based addition to the NIO Selector, which
> I've previously talked through a bit with Alan Bateman. The goal of the
> callback based selector is to avoid the current pattern of calling
> select/selectNow on a Nio selector and then having to iterate over a
> hashmap produced. This pattern being quite object allocation heavy for a
> critical path and also involving obtaining and releasing multiple locks.
> I'd like to propose that the following patch, which adds the ability to
> perform a select on a Selector that takes a callback handler.
>
> http://cr.openjdk.java.net/~rwarburton/select-now-4/
>
> I'm happy to iterate on the patch a bit based upon people's feedback and
> discuss any potential concerns or issues that you may have with the
> patch. Looking forward to hearing your feedback.
Hi Richard. Selector specifies a relatively extensive contract with
respect to locking. It is not clear from the documentation of the new
method what the behavior is with respect to the various selector locks.
Looking at the code, it seems to sidestep locking altogether during
the callback process, is that an accurate assessment?
Also, any thoughts on compatibility implications in terms of existing
Selector subclasses? I don't think such a thing is common, but the
class is public and has an accessible constructor. The addition of the
new abstract method could theoretically result in unexpected
AbstractMethodErrors.
--
- DML
More information about the nio-dev
mailing list