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 One2NetChannelThe underlying One2NetChannel used by this channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAny2NetChannel(One2NetChannel channel) Constructor wrapping an existing One2NetChannel in an Any2NetChannel -
Method Summary
Modifier and TypeMethodDescriptionvoidasyncWrite(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 Any2NetChannelvoiddestroy()Removes the channel from the ChannelManager, and sets the state to DESTROYEDGets the NetChannelLocation of the input end this channel is connected to.voidpoison(int strength) Poisons the underlying channelvoidsetEncoder(NetworkMessageFilter.FilterTx encoder) Sets the underlying message filtervoidWrites 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:
poisonin 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:
getLocationin 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:
writein 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:
asyncWritein 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
-
setEncoder
Sets the underlying message filter- Specified by:
setEncoderin interfaceNetChannelOutput<T>- Parameters:
encoder- The new message filter to use
-