How to use channel groups from custom implementation?
Alan.Bateman at oracle.com
Wed Jul 13 01:44:51 PDT 2011
> It's not clear how to make use of AsynchronousChannelGroup. The user invokes
> open(AsynchronousChannelGroup) on my custom AsynchronousByteChannel. What
> next? How am I supposed to gain access to the underlying Executor used to
> invoke the CompletionHandlers? How am I supposed to gain access to the
> default channel group if he invokes open()?
Channels in the same group share resources such as I/O event or
completion ports. All the details on demultiplexing are highly
provider/implementation specific and there isn't any supported way to
attach a new channel type to an existing provider implementation. It's a
similar to what we have with Selector where someone can't develop a
SelectableChannel implementation and have it work with the default
provider. Instead the replacement unit is the complete ball of wax that
is the SelectorProvider or AsynchronousChannelProvider and the
associated channel types.
That said, for experimental purposes then it may be useful to know our
AsynchronousChannelGroup implementation implements Executor so there is
a means (albeit not supported) to execute tasks on the thread pool.
Whether this is efficient or not depends will depend on the type of
thread pool. With a fixed thread pool then all threads are normally
blocked waiting on I/O events and so if you execute some arbitrary task
then one of these threads will require to be woken up in order to
execute the task.
The default channel group cannot be shutdown so this is why there isn't
a method to get a reference to it.
More information about the nio-discuss