Package org.jcsp.lang
Class ChannelInputImpl<T>
- java.lang.Object
-
- org.jcsp.lang.ChannelInputImpl<T>
-
- All Implemented Interfaces:
ChannelInput<T>
,Poisonable
- Direct Known Subclasses:
RejectableChannelInputImpl
class ChannelInputImpl<T> extends java.lang.Object implements ChannelInput<T>
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelInternals<T>
channel
private int
immunity
-
Constructor Summary
Constructors Constructor Description ChannelInputImpl(ChannelInternals _channel, int _immunity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endRead()
End an extended rendezvous.void
poison(int strength)
This injects poison into the channel.T
read()
Read an Object from the channel.T
startRead()
Begin an extended rendezvous read from the channel.
-
-
-
Field Detail
-
channel
private ChannelInternals<T> channel
-
immunity
private int immunity
-
-
Constructor Detail
-
ChannelInputImpl
ChannelInputImpl(ChannelInternals _channel, int _immunity)
-
-
Method Detail
-
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<T>
-
read
public T read()
Description copied from interface:ChannelInput
Read an Object from the channel.- Specified by:
read
in interfaceChannelInput<T>
- Returns:
- the object read from the channel
-
startRead
public T 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<T>
- Returns:
- The object read from the channel
-
poison
public void poison(int strength)
Description copied from interface:Poisonable
This injects poison into the channel. If the channel was not explicitly constructed to be poisonable or if the strength of poison is not greater than the channel immunity level, the poison will have no effect.- Specified by:
poison
in interfacePoisonable
- Parameters:
strength
- the strength of the poison (must be >= 0).
-
-