Class Net2AnyChannel
- java.lang.Object
-
- org.jcsp.net.Net2AnyChannel
-
- All Implemented Interfaces:
ChannelInput
,Poisonable
,SharedChannelInput
,NetChannelInput
,NetSharedChannelInput
,Networked
class Net2AnyChannel extends java.lang.Object implements NetSharedChannelInput, Networked
A channel for network input (RX). This is a "Net2Any" channel, which can be safely used by multiple readers on the same Node.
-
-
Field Summary
Fields Modifier and Type Field Description private RejectableChannel
ch
The local channel used for output from the recieving processprivate java.lang.String
label
The channel name.private NetChannelInputProcess
netChannelInputProcess
-
Constructor Summary
Constructors Constructor Description Net2AnyChannel()
Creates an anonymous input channel.Net2AnyChannel(java.lang.String label)
Net2AnyChannel(java.lang.String label, ChannelDataStore buffer)
Net2AnyChannel(ChannelDataStore buffer)
Creates an anonymous, buffered input channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroyReader()
Destroys the channel end and frees any resources within the JCSP.NET infrastructure.void
endRead()
End an extended rendezvous.NetChannelLocation
getChannelLocation()
Returns the location of theNetworked
ChannelInput
.java.lang.Class
getFactoryClass()
Returns a Class file of the factory used to construct the channel end.void
poison(int strength)
Currently, network channels are unpoisonable so this method has no effect.java.lang.Object
read()
Read data from this channel.java.lang.Object
startRead()
Begin an extended rendezvous read from the channel.
-
-
-
Field Detail
-
label
private final java.lang.String label
The channel name.
-
ch
private RejectableChannel ch
The local channel used for output from the recieving process
-
netChannelInputProcess
private NetChannelInputProcess netChannelInputProcess
-
-
Constructor Detail
-
Net2AnyChannel
public Net2AnyChannel(java.lang.String label) throws java.lang.NullPointerException
- Throws:
java.lang.NullPointerException
-
Net2AnyChannel
public Net2AnyChannel()
Creates an anonymous input channel.
To create writers that write to this channel, you need to call getChannelName() to get a valid name for this channel. You will need to use some other means (e.g. a named channel) to pass the channel name to the writing computer.
-
Net2AnyChannel
public Net2AnyChannel(ChannelDataStore buffer)
Creates an anonymous, buffered input channel.
To create writers that write to this channel, you need to call getChannelName() to get a valid name for this channel. You will need to use some other means (e.g. a named channel) to pass the channel name to the writing computer.
- Parameters:
buffer
- The ChannelDataStore to use.
-
Net2AnyChannel
public Net2AnyChannel(java.lang.String label, ChannelDataStore buffer)
-
-
Method Detail
-
read
public java.lang.Object read()
Read data from this channel. This can safely be called by multiple readers.- Specified by:
read
in interfaceChannelInput
- Returns:
- The object read from the network.
-
startRead
public java.lang.Object startRead()
Description copied from interface:ChannelInput
Begin an extended rendezvous read from the channel. An extended rendezvous is not completed until the reader has completed its extended action. This method starts an extended rendezvous. When a writer to this channel writes, this method returns what was sent immediately. The extended rendezvous continues with reader actions until the reader invokes
. Only then will the writer be released (from itsendRead
method). The writer is unaware of the extended nature of the communication.write
The reader process must call
at some point after this function, otherwise the writer will not be freed and deadlock will probably follow.endRead
The reader process may perform any actions between calling
andstartRead
, including communications on other channels. Further communications on this channel, of course, should not be made.endRead
An extended rendezvous may be started after the channel's Guard has been selected by an
Alternative
(i.e.
instead ofstartRead
).read
- Specified by:
startRead
in interfaceChannelInput
- Returns:
- The object read from the channel
-
endRead
public void endRead()
Description copied from interface:ChannelInput
End an extended rendezvous. It must be invoked once (and only once) following a
.startRead
- Specified by:
endRead
in interfaceChannelInput
-
poison
public void poison(int strength)
Currently, network channels are unpoisonable so this method has no effect.- Specified by:
poison
in interfacePoisonable
- Parameters:
strength
- the strength of the poison (must be >= 0).
-
getChannelLocation
public NetChannelLocation getChannelLocation()
Description copied from interface:Networked
Returns the location of theNetworked
ChannelInput
.- Specified by:
getChannelLocation
in interfaceNetworked
- Returns:
- the
NetChannelLocation
object.
-
getFactoryClass
public java.lang.Class getFactoryClass()
Description copied from interface:NetChannelInput
Returns a Class file of the factory used to construct the channel end.
- Specified by:
getFactoryClass
in interfaceNetChannelInput
- Returns:
- the
Class
of the factory class.
-
destroyReader
public void destroyReader()
Description copied from interface:NetChannelInput
Destroys the channel end and frees any resources within the JCSP.NET infrastructure.
- Specified by:
destroyReader
in interfaceNetChannelInput
-
-