Class RejectableAltingChannelInputImpl
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingChannelInput
-
- org.jcsp.lang.RejectableAltingChannelInput
-
- org.jcsp.lang.RejectableAltingChannelInputImpl
-
- All Implemented Interfaces:
ChannelInput
,Poisonable
,RejectableChannelInput
class RejectableAltingChannelInputImpl extends RejectableAltingChannelInput
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelInternals
channel
private int
immunity
-
Constructor Summary
Constructors Constructor Description RejectableAltingChannelInputImpl(ChannelInternals _channel, int _immunity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
disable()
Disables the guard for selection.(package private) boolean
enable(Alternative alt)
Returns true if the event is ready.void
endRead()
End an extended rendezvous.boolean
pending()
Returns whether there is data pending on this channel.void
poison(int strength)
This injects poison into the channel.java.lang.Object
read()
Read an Object from the channel.void
reject()
Reject any data pending instead of reading it.java.lang.Object
startRead()
Begin an extended rendezvous read from the channel.
-
-
-
Field Detail
-
channel
private ChannelInternals channel
-
immunity
private int immunity
-
-
Constructor Detail
-
RejectableAltingChannelInputImpl
RejectableAltingChannelInputImpl(ChannelInternals _channel, int _immunity)
-
-
Method Detail
-
pending
public boolean pending()
Description copied from class:AltingChannelInput
Returns 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:
pending
in classAltingChannelInput
- Returns:
- state of the channel.
-
disable
boolean disable()
Description copied from class:Guard
Disables the guard for selection. Returns true if the event was ready.Note: this method should only be called by the Alternative class
-
enable
boolean enable(Alternative alt)
Description copied from class:Guard
Returns 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
-
endRead
public void endRead()
Description copied from interface:ChannelInput
End an extended rendezvous. It must be invoked once (and only once) following a
.startRead
-
read
public java.lang.Object read()
Description copied from interface:ChannelInput
Read an Object from the channel.- Returns:
- the object read from the channel
-
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
- 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.- Parameters:
strength
- the strength of the poison (must be >= 0).
-
reject
public void reject()
Description copied from class:RejectableAltingChannelInput
Reject any data pending instead of reading it. The currently blocked writer will receive aChannelDataRejectedException
.- Specified by:
reject
in interfaceRejectableChannelInput
- Specified by:
reject
in classRejectableAltingChannelInput
-
-