Callback Based Selectors
Alan Bateman
Alan.Bateman at oracle.com
Thu Mar 15 12:11:48 UTC 2018
On 15/03/2018 11:49, David Lloyd wrote:
> :
>
> A specialized set isn't really interesting to me because I have to
> process it outside of the lock(s) anyway. ArrayDeque works well for
> me because once it's sized, it's very fast, and by using the callback
> to populate it we avoid the extra add/remove operation on the key set,
> which is already worth something to me.
>
Which lock are you trying to avoid here? Selection operations are
specified to synchronize on the selector, its key set, and the
selected-key set. The existing select methods add to the selected-key
set and must maintain the invariant that the selected-key set is a
subset of the selector's key set. The method on the table has the
potential to release the locks for the key set and selected-key once it
has processed the cancelled-set key, meaning that the only lock held
when invoking the consumer is the selector lock.
-Alan
More information about the nio-dev
mailing list