Class AltingChannelInputSymmetricImpl<T>
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingChannelInput<T>
-
- org.jcsp.lang.AltingChannelInputSymmetricImpl<T>
-
- All Implemented Interfaces:
ChannelInput<T>,MultiwaySynchronisation,Poisonable
class AltingChannelInputSymmetricImpl<T> extends AltingChannelInput<T> implements MultiwaySynchronisation
-
-
Field Summary
Fields Modifier and Type Field Description private AltingBarrierabprivate ChannelInput<T>inprivate booleansyncDone
-
Constructor Summary
Constructors Constructor Description AltingChannelInputSymmetricImpl(AltingBarrier ab, ChannelInput<T> in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleandisable()Disables the guard for selection.(package private) booleanenable(Alternative alt)Returns true if the event is ready.voidendRead()End an extended rendezvous.booleanpending()Returns whether there is data pending on this channel.voidpoison(int strength)This injects poison into the channel.Tread()Read an Object from the channel.TstartRead()Begin an extended rendezvous read from the channel.
-
-
-
Field Detail
-
ab
private final AltingBarrier ab
-
in
private final ChannelInput<T> in
-
syncDone
private boolean syncDone
-
-
Constructor Detail
-
AltingChannelInputSymmetricImpl
public AltingChannelInputSymmetricImpl(AltingBarrier ab, ChannelInput<T> in)
-
-
Method Detail
-
enable
boolean enable(Alternative alt)
Description copied from class:GuardReturns true if the event is ready. Otherwise, this enables the guard for selection and returns false.Note: this method should only be called by the Alternative class
-
disable
boolean disable()
Description copied from class:GuardDisables the guard for selection. Returns true if the event was ready.Note: this method should only be called by the Alternative class
-
read
public T read()
Description copied from interface:ChannelInputRead an Object from the channel.- Specified by:
readin interfaceChannelInput<T>- Returns:
- the object read from the channel
-
pending
public boolean pending()
Description copied from class:AltingChannelInputReturns whether there is data pending on this channel.Note: if there is, it won't go away until you read it. But if there isn't, there may be some by the time you check the result of this method.
- Specified by:
pendingin classAltingChannelInput<T>- Returns:
- state of the channel.
-
poison
public void poison(int strength)
Description copied from interface:PoisonableThis 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:
poisonin interfacePoisonable- Parameters:
strength- the strength of the poison (must be >= 0).
-
endRead
public void endRead()
Description copied from interface:ChannelInputEnd an extended rendezvous. It must be invoked once (and only once) following a.startRead- Specified by:
endReadin interfaceChannelInput<T>
-
startRead
public T startRead()
Description copied from interface:ChannelInputBegin 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 itsendReadmethod). The writer is unaware of the extended nature of the communication.writeThe reader process must call
at some point after this function, otherwise the writer will not be freed and deadlock will probably follow.endReadThe 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.endReadAn extended rendezvous may be started after the channel's Guard has been selected by an
Alternative(i.e.instead ofstartRead).read- Specified by:
startReadin interfaceChannelInput<T>- Returns:
- The object read from the channel
-
-