Package org.jcsp.net2
Class Any2NetChannel<T>
java.lang.Object
org.jcsp.net2.Any2NetChannel<T>
- All Implemented Interfaces:
ChannelOutput<T>
,Poisonable
,SharedChannelOutput<T>
,NetChannelOutput<T>
,NetSharedChannelOutput<T>
,Networked
An outputting network channel (TX) that can be safely shared amongst multiple writers (Any2Net). This is the concrete
implementation of the construct. For information on the user level interface, see NetSharedChannelOutput
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final One2NetChannel
The underlying One2NetChannel used by this channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Any2NetChannel
(One2NetChannel channel) Constructor wrapping an existing One2NetChannel in an Any2NetChannel -
Method Summary
Modifier and TypeMethodDescriptionvoid
asyncWrite
(T object) Writes asynchronously to the underlying channel.(package private) static <T2> Any2NetChannel<T2>
create
(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) Static factory method used to create an Any2NetChannelvoid
destroy()
Removes the channel from the ChannelManager, and sets the state to DESTROYEDGets the NetChannelLocation of the input end this channel is connected to.void
poison
(int strength) Poisons the underlying channelvoid
setEncoder
(NetworkMessageFilter.FilterTx encoder) Sets the underlying message filtervoid
Writes an object to the underlying channel.
-
Field Details
-
chan
The underlying One2NetChannel used by this channel. This class acts like a wrapper, protecting the underlying unshared connection.
-
-
Constructor Details
-
Any2NetChannel
Constructor wrapping an existing One2NetChannel in an Any2NetChannel- Parameters:
channel
- The One2NetChannel to be wrapped.
-
-
Method Details
-
create
static <T2> Any2NetChannel<T2> create(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter) throws JCSPNetworkException Static factory method used to create an Any2NetChannel- Parameters:
loc
- The location of the input channel endimmunity
- The immunity level of the channelfilter
- The filter used to convert the object being sent into bytes- Returns:
- A new Any2NetChannel connected to the input end.
- Throws:
JCSPNetworkException
- Thrown if a connection to the Node cannot be made.
-
poison
public void poison(int strength) Poisons the underlying channel- Specified by:
poison
in interfacePoisonable
- Parameters:
strength
- The strength of the poison being put on the channel
-
getLocation
Gets the NetChannelLocation of the input end this channel is connected to.- Specified by:
getLocation
in interfaceNetworked
- Returns:
- The location of the input end that this output end is connected to.
-
write
Writes an object to the underlying channel.- Specified by:
write
in interfaceChannelOutput<T>
- Parameters:
object
- The Object to write to the channel- Throws:
JCSPNetworkException
- Thrown if something happens in the underlying architecturePoisonException
- Thrown if the channel has been poisoned.
-
asyncWrite
Writes asynchronously to the underlying channel.- Specified by:
asyncWrite
in interfaceNetChannelOutput<T>
- Parameters:
object
- The object to write to the channel- Throws:
JCSPNetworkException
- Thrown if something happens in the underlying architecturePoisonException
- Thrown is the channel has been poisoned
-
destroy
public void destroy()Removes the channel from the ChannelManager, and sets the state to DESTROYED -
setEncoder
Sets the underlying message filter- Specified by:
setEncoder
in interfaceNetChannelOutput<T>
- Parameters:
encoder
- The new message filter to use
-