Package org.jcsp.net2
Class One2NetChannel<T>
java.lang.Object
org.jcsp.net2.One2NetChannel<T>
- All Implemented Interfaces:
ChannelOutput<T>
,Poisonable
,NetChannelOutput<T>
,Networked
An outputting end of a networked channel (TX). This is a concrete implementation created internally by JCSP. For
information on how to use networked channels, and how to create them, see the relevant documentation.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelData
A structure containing the information on the state of the channel.private final boolean
Flag to determine if this is a locally connected channel or notprivate final Link
The actual Link this output channel sends on.private final ChannelData
This is used if we are ever connected locally.private final NetChannelLocation
The local channel end locationprivate NetworkMessageFilter.FilterTx
The filter used to encode outgoing messagesprivate final NetChannelLocation
The location that this channel is connected to (the input channel ends location)private final AltingChannelInput
The channel used to receive acknowledgements from the input end via the Link.private final ChannelOutput
The channel connecting to the Link that connects to the networked input end of this channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
One2NetChannel
(AltingChannelInput ackChannel, ChannelOutput toLink, Link link, ChannelData chanData, NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) Private constructor for creating a One2NetChannel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
asyncWrite
(T object) Asynchronously writes an object to the channel(package private) static <T2> One2NetChannel
<T2> create
(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) Creates a new One2NetChannel by connecting to an already created NetChannelInputvoid
destroy()
Destroys the channel and removes it from the ChannelManager.(package private) final ChannelData
Gets the channel data state for this channel.Gets the NetChannelLocation that this channel is connected to (i.e.(package private) NetChannelLocation
Gets the local NetChannelLocation that represents this channel.void
poison
(int strength) Poisons the underlying channel.void
setEncoder
(NetworkMessageFilter.FilterTx encoder) Sets the underlying message filtervoid
Writes an object to the input end
-
Field Details
-
toLinkTx
The channel connecting to the Link that connects to the networked input end of this channel. -
linkConnectedTo
The actual Link this output channel sends on. We keep this as it allows us to register and unregister with the Link as we are created and destroyed, allowing the Link to inform the channel when a Link goes down. -
localChannel
This is used if we are ever connected locally. We use this to check the state of a locally connected channel prior to sending a message. -
theAckChannel
The channel used to receive acknowledgements from the input end via the Link. -
data
A structure containing the information on the state of the channel. -
remoteLocation
The location that this channel is connected to (the input channel ends location) -
localLocation
The local channel end location -
isLocal
private final boolean isLocalFlag to determine if this is a locally connected channel or not -
messageFilter
The filter used to encode outgoing messages
-
-
Constructor Details
-
One2NetChannel
private One2NetChannel(AltingChannelInput ackChannel, ChannelOutput toLink, Link link, ChannelData chanData, NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) Private constructor for creating a One2NetChannel. This is called by the create method.- Parameters:
ackChannel
- The channel used to receive acknowledgements from LinkstoLink
- The channel used to send messages to the input endlink
- The Link that this channel is connected tochanData
- The structure used to store the state of the channelloc
- The location of the input end that this channel is connected toimmunity
- The poison immunity level of the channelfilter
- Filter used to encode outgoing messages
-
-
Method Details
-
create
static <T2> One2NetChannel<T2> create(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException Creates a new One2NetChannel by connecting to an already created NetChannelInput- Parameters:
loc
- The location of the NetChannelInputimmunity
- The immunity level of the channelfilter
- The filter used to encode outgoing messages- Returns:
- A new One2NetChannel
- Throws:
JCSPNetworkException
- Thrown if the connection to the remote Node fails
-
poison
public void poison(int strength) Poisons the underlying channel.- Specified by:
poison
in interfacePoisonable
- Parameters:
strength
- The strength of the poison being placed on the channel
-
getLocation
Gets the NetChannelLocation that this channel is connected to (i.e. the input end location)- Specified by:
getLocation
in interfaceNetworked
- Returns:
- The NetChannelLocation that this channel is connected to
-
localLocation
NetChannelLocation localLocation()Gets the local NetChannelLocation that represents this channel.- Returns:
- The local location of the output end
-
write
Writes an object to the input end- Specified by:
write
in interfaceChannelOutput<T>
- Parameters:
object
- The object to send to the input end.- Throws:
JCSPNetworkException
- Thrown if something goes wrong in the network architecturePoisonException
- Thrown if the channel has been poisoned
-
asyncWrite
Asynchronously writes an object to the channel- Specified by:
asyncWrite
in interfaceNetChannelOutput<T>
- Parameters:
object
- The object being written to the channel- Throws:
JCSPNetworkException
- Thrown when something goes wrong in the network architecturePoisonException
- Thrown if the channel is poisoned
-
getChannelData
Gets the channel data state for this channel.- Returns:
- ChannelData for this channel
-
destroy
public void destroy()Destroys the channel and removes it from the ChannelManager. -
setEncoder
Sets the underlying message filter- Specified by:
setEncoder
in interfaceNetChannelOutput<T>
- Parameters:
encoder
- The new message filter to use
-