final class Net2AnyChannel<T> extends java.lang.Object implements NetSharedChannelInput<T>
NetChannelInput,
NetSharedChannelInput,
NetChannel| Modifier and Type | Field and Description |
|---|---|
private Net2OneChannel |
actualChannel
The underlying Net2OneChannel that this object wraps around
|
private Mutex |
mutex
A mutual exclusion lock, allowing only one process access to perform a read operation at a time
|
| Modifier | Constructor and Description |
|---|---|
private |
Net2AnyChannel(Net2OneChannel chan)
Constructor for Net2AnyChannel
|
| Modifier and Type | Method and Description |
|---|---|
(package private) static <T2> Net2AnyChannel<T2> |
create(int index,
int poisonImmunity,
NetworkMessageFilter.FilterRx filter)
Static factory method for creating a new instance of Net2AnyChannel, given a particular index
|
(package private) static <T2> Net2AnyChannel<T2> |
create(int poisonImmunity,
NetworkMessageFilter.FilterRx filter)
A static factory method to create a new Net2AnyChannel object
|
void |
destroy()
Destroys the channel
|
void |
endRead()
Ends an extended read operation
|
NetLocation |
getLocation()
Gets the channel location of this channel
|
void |
poison(int strength)
Poisons the underlying channel
|
T |
read()
Reads the next message from the channel
|
void |
setDecoder(NetworkMessageFilter.FilterRx decoder)
Sets the underlying message filter
|
T |
startRead()
Begins an extended read operation on the channel
|
private final Net2OneChannel actualChannel
private final Mutex mutex
private Net2AnyChannel(Net2OneChannel chan)
chan - The underlying channel that this object will wrap aroundstatic <T2> Net2AnyChannel<T2> create(int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws JCSPNetworkException
poisonImmunity - The immunity level of the channelfilter - The filter used to convert an incoming byte array into an objectJCSPNetworkException - Thrown if there is a problem creating the underlying channelstatic <T2> Net2AnyChannel<T2> create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws java.lang.IllegalArgumentException, JCSPNetworkException
index - The index to create the channel withpoisonImmunity - the immunity level of the channelsfilter - The filter used to convert the byte array back into an objectjava.lang.IllegalArgumentException - Thrown if a channel with the given index already existsJCSPNetworkException - Thrown if something goes wrong during the creation of the underlying channelpublic void endRead()
throws java.lang.IllegalStateException,
JCSPNetworkException,
NetworkPoisonException
endRead in interface ChannelInput<T>java.lang.IllegalStateException - Thrown if the channel is not in an extended read stateJCSPNetworkException - Thrown if something goes wrong in the underlying network architectureNetworkPoisonException - Thrown if the underlying channel has been poisonedpublic T read() throws JCSPNetworkException, java.lang.IllegalStateException, NetworkPoisonException
read in interface ChannelInput<T>JCSPNetworkException - Thrown if something goes wrong in the underlying architecturejava.lang.IllegalStateException - Thrown if the channel is in an extended read stateNetworkPoisonException - Thrown if the channel has been poisonedpublic T startRead() throws JCSPNetworkException, NetworkPoisonException, java.lang.IllegalStateException
startRead in interface ChannelInput<T>JCSPNetworkException - Thrown if something goes wrong in the underlying architectureNetworkPoisonException - Thrown if the channel has been poisonedjava.lang.IllegalStateException - Thrown if the channel is in an extended read statepublic void poison(int strength)
poison in interface Poisonablestrength - The strength of the poisonpublic NetLocation getLocation()
getLocation in interface Networkedpublic void setDecoder(NetworkMessageFilter.FilterRx decoder)
setDecoder in interface NetChannelInput<T>decoder - The new message filter to use