Package org.jcsp.net2
Class Net2OneChannel<T>
java.lang.Object
org.jcsp.lang.Guard
org.jcsp.lang.AltingChannelInput<T>
org.jcsp.lang.AltingChannelInputWrapper<T>
org.jcsp.net2.NetAltingChannelInput<T>
org.jcsp.net2.Net2OneChannel<T>
- All Implemented Interfaces:
ChannelInput<T>
,Poisonable
,NetChannelInput<T>
,Networked
A concrete implementation of a NetAltingChannelInput. This is a hidden class created by the architecture. To create
an instance of this object, use the NetChannel factory, or the CNS.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelData
The ChannelData structure representing this channel.private final AltingChannelInput
The input channel coming into the networked channel input object from Links or locally connected net channel outputs.private NetworkMessage
The lastRead ChannelMessage.private final NetChannelLocation
The location of this channelprivate NetworkMessageFilter.FilterRx
The filter used to convert the incoming byte array into an object -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Net2OneChannel
(AltingChannelInput input, ChannelData chanData, NetworkMessageFilter.FilterRx filter) Private constructor for creating a new instance of a Net2OneChannel. -
Method Summary
Modifier and TypeMethodDescription(package private) static <T2> Net2OneChannel
<T2> create
(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) Static factory method used to create a new Net2OneChannel with a given index.(package private) static <T2> Net2OneChannel
<T2> create
(int poisonImmunity, NetworkMessageFilter.FilterRx filter) Static factory method used to create a new Net2OneChannel.void
destroy()
Destroys the underlying channelvoid
endRead()
Ends an extended read operation.(package private) final ChannelData
Gets the channel data object for this channel.Returns the NetChannelLocation of the channelboolean
pending()
Checks if any data is waiting on the channel.void
poison
(int strength) Poisons the underlying channelread()
Reads the next message from the channelvoid
setDecoder
(NetworkMessageFilter.FilterRx decoder) Sets the underlying message filterPerforms an extended read operation on the channelMethods inherited from class org.jcsp.lang.AltingChannelInputWrapper
getChannel, setChannel
-
Field Details
-
in
The input channel coming into the networked channel input object from Links or locally connected net channel outputs. -
data
The ChannelData structure representing this channel. -
lastRead
The lastRead ChannelMessage. Used during an extended read operation to allow the ACK message to be sent to the correct Node. -
messageFilter
The filter used to convert the incoming byte array into an object -
location
The location of this channel
-
-
Constructor Details
-
Net2OneChannel
private Net2OneChannel(AltingChannelInput input, ChannelData chanData, NetworkMessageFilter.FilterRx filter) throws JCSPNetworkException Private constructor for creating a new instance of a Net2OneChannel. This is called by the create method to create the channel.- Parameters:
input
- The input channel connecting to the networked channel.chanData
- The ChannelData object representing the networked channel.filter
- The filter used to convert the incoming byte array to an object- Throws:
JCSPNetworkException
-
-
Method Details
-
create
Static factory method used to create a new Net2OneChannel. Used internally within the architecture.- Parameters:
poisonImmunity
- The immunity level of the channelfilter
- The filter on the channel used to convert read bytes into an object- Returns:
- A new Net2OneChannel
-
create
static <T2> Net2OneChannel<T2> create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws IllegalArgumentException Static factory method used to create a new Net2OneChannel with a given index. Used internally within the architecture- Parameters:
index
- The index to create the channel withpoisonImmunity
- The immunity level of the channelfilter
- The filter used to take the incoming byte array and convert it into an object- Returns:
- A new Net2OneChannel
- Throws:
IllegalArgumentException
- Thrown if the index given is already allocated within the ChannelManager
-
endRead
Ends an extended read operation.- Specified by:
endRead
in interfaceChannelInput<T>
- Overrides:
endRead
in classAltingChannelInputWrapper<T>
- Throws:
IllegalStateException
- Thrown if the method is called when the channel is not in an extended read stateJCSPNetworkException
- Thrown if something goes wrong in the underlying architectureNetworkPoisonException
- Thrown if the channel has been poisoned- See Also:
-
pending
Checks if any data is waiting on the channel.- Overrides:
pending
in classAltingChannelInputWrapper<T>
- Returns:
- True if data is ready, false otherwise.
- Throws:
JCSPNetworkException
- Thrown if the channel has been destroyedNetworkPoisonException
- Thrown if the channel has poisoned
-
poison
public void poison(int strength) Poisons the underlying channel- Specified by:
poison
in interfacePoisonable
- Overrides:
poison
in classAltingChannelInputWrapper<T>
- Parameters:
strength
- The strength of the poison
-
read
Reads the next message from the channel- Specified by:
read
in interfaceChannelInput<T>
- Overrides:
read
in classAltingChannelInputWrapper<T>
- Returns:
- The message read from the channel
- Throws:
JCSPNetworkException
- Thrown if something goes wrong in the underlying architectureNetworkPoisonException
- Thrown if the channel is poisonedIllegalStateException
- Thrown if the channel is in an extended read state
-
startRead
Performs an extended read operation on the channel- Specified by:
startRead
in interfaceChannelInput<T>
- Overrides:
startRead
in classAltingChannelInputWrapper<T>
- Returns:
- The message read from the channel
- Throws:
JCSPNetworkException
- Thrown if something goes wrong in the underlying architectureIllegalStateException
- Thrown if the channel is already in an extended read stateNetworkPoisonException
- Thrown if the channel is poisoned.- See Also:
-
getLocation
Returns the NetChannelLocation of the channel- Returns:
- Location of this channel
-
destroy
public void destroy()Destroys the underlying channel -
getChannelData
Gets the channel data object for this channel.- Returns:
- The ChannelData for this Channel
-
setDecoder
Sets the underlying message filter- Parameters:
decoder
- The message filter to use
-