Package co.paralleluniverse.fibers.io
Class ChannelGroup
- java.lang.Object
-
- co.paralleluniverse.fibers.io.ChannelGroup
-
public abstract class ChannelGroup extends java.lang.Object
A grouping of channels for the purpose of resource sharing.A channel group encapsulates the mechanics required to handle the completion of I/O operations initiated by channels that are bound to the group. A group has an associated thread pool which polls IO events sent by the OS.
-
-
Constructor Summary
Constructors Constructor Description ChannelGroup()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
shutdown()
Shutdown the channel group.static ChannelGroup
withFixedThreadPool(int nThreads, java.util.concurrent.ThreadFactory threadFactory)
Creates a channel group with a fixed thread pool.static ChannelGroup
withThreadPool(java.util.concurrent.ExecutorService executor)
Creates a channel group with a given thread pool.
-
-
-
Method Detail
-
withFixedThreadPool
public static ChannelGroup withFixedThreadPool(int nThreads, java.util.concurrent.ThreadFactory threadFactory) throws java.io.IOException
Creates a channel group with a fixed thread pool.The resulting channel group reuses a fixed number of threads. At any point, at most
nThreads
threads will be active processing tasks that are submitted to handle I/O events and dispatch completion results for operations initiated on channels in the group.- Parameters:
nThreads
- The number of threads in the poolthreadFactory
- The factory to use when creating new threads- Returns:
- A new asynchronous channel group
- Throws:
java.lang.IllegalArgumentException
- IfnThreads <= 0
java.io.IOException
- If an I/O error occurs
-
withThreadPool
public static ChannelGroup withThreadPool(java.util.concurrent.ExecutorService executor) throws java.io.IOException
Creates a channel group with a given thread pool.- Parameters:
executor
- The thread pool for the resulting group- Returns:
- A new asynchronous channel group
- Throws:
java.io.IOException
-
shutdown
public abstract void shutdown()
Shutdown the channel group.
-
-