Interface IOSubchannel
- All Superinterfaces:
Associator
,Channel
,Eligible
,Subchannel
- All Known Subinterfaces:
SocketIOChannel
- All Known Implementing Classes:
IOSubchannel.DefaultIOSubchannel
,LinkedIOSubchannel
,ProcessManager.ProcessChannel
,SocketConnectionManager.SocketChannelImpl
An I/O subchannel has an initiator that creates and manages the subchannel. Events fired by the initiator are said to flow downstream on the channel. Events fired by components in response are said to flow upstream.
Upstream and downstream events are usually handled by two different pipelines
managed by the initiator. One pipeline, accessible only to the initiator,
handles the downstream events. The other, made available as a property of the
I/O subchannel (see responsePipeline()
and respond(Event)
),
handles the upstream events. Of course, any pipeline can be
used to send events upstream to the initiator component. However, using
arbitrary pipelines holds the risk that events aren’t delivered in the
intended order.
An I/O subchannel also provides associated buffer pools for byte buffers and character buffers. Buffers used in responses (upstream events) should be acquired from these pools only. The initiator should initialize the pools in such a way that it suits its needs.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
Nested classes/interfaces inherited from interface org.jgrapes.core.Subchannel
Subchannel.DefaultSubchannel
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the subchannel’s byte buffer pool.Get the subchannel’s char buffer pool.static IOSubchannel
create
(Component component, EventPipeline responsePipeline) Creates a new subchannel of the given component’s channel with the given event pipeline and a buffer pool with two buffers sized 4096.default <T extends Event<?>>
Trespond
(T event) Fires the given event on this subchannel using the subchannel’s response pipeline.Gets theEventPipeline
that can be used for events going back to the initiator of this connection.Methods inherited from interface org.jgrapes.core.Associator
associated, associated, associated, associated, associatedGet, setAssociated
Methods inherited from interface org.jgrapes.core.Subchannel
defaultCriterion, isEligibleFor, mainChannel
-
Method Details
-
responsePipeline
Gets theEventPipeline
that can be used for events going back to the initiator of this connection.Consistently using this event pipeline for response events ensures that the events are written in proper sequence.
- Returns:
- the event pipeline
-
byteBufferPool
Get the subchannel’s byte buffer pool.- Returns:
- the buffer pool
-
charBufferPool
Get the subchannel’s char buffer pool.- Returns:
- the buffer pool
-
respond
Fires the given event on this subchannel using the subchannel’s response pipeline.Effectively, fire(someEvent) is a shortcut for getResponsePipeline.add(someEvent, this).
- Type Parameters:
T
- the event’s type- Parameters:
event
- the event to fire- Returns:
- the event (for easy chaining)
-
create
Creates a new subchannel of the given component’s channel with the given event pipeline and a buffer pool with two buffers sized 4096.- Parameters:
component
- the component used to get the main channelresponsePipeline
- the response pipeline- Returns:
- the subchannel
-