A central concept introduced by this package are
IOSubchannels. They allow the
Output events from different connections
to be transferred on the same
Details can be found in the description of the interface.
Connection provider components actively create a connection to some
other process or wait for other processes to create a connection that
is used to exchange information. Such components must (directly or
indirectly) register as generator
while connections are active or the components are waiting for incoming
connections to prevent premature termination of the framework.
When a new connection is established, these components usually create
IOSubchannel that represents the
connection with the other process. On this sub channel, the connection
provider components should send events according to the following
Openingevent to inform other interested components about the new I/O subchannel. A component’s handler might e.g. send a
SaveInputevent to log all input on this channel. Only after the completion of
Openingevent should the next event be sent on the I/O subchannel.
Openedevent (or some derived class with more information about the type of connection that has been opened).
Inputevents as data from the client arrives.
Closeevent that indicates that the connection has terminated.
The data associated with
Output events is stored in NIO buffers.
JGrapes manages these buffers in pools. To support this, JGrapes
defines the class
that wraps a NIO buffer, adding the information required for
Pooling is not done to avoid garbage collection, but for shaping streams of data. Imagine a pipeline where stage A produces data much faster than stage B can handle it. If we allowed arbitrary buffer allocation, it might happen that a lot of memory is used for buffers created by stage A and not yet consumed by stage B.
Using a buffer pool limits the the production rate of stage A without reducing the overall performance. When all buffers are in use, stage A has to wait until some data is consumed by stage B and a buffer is freed. But as soon as this is the case, stage A can continue to produce data in parallel (unless you set the pool size to 1, of course).
ClassDescriptionA component that reads from or writes to a file.A component that watches for new input on an
InputStream.Represents a subchannel for grouping input and output events related to an I/O resource such as an opened file or a network connection.A simple implementation of
IOSubchannel.A helper component that provides the central hub for non blocking I/O components.Defines the contract between a component using non blocking I/O and the