Package org.jcsp.lang

Class Alternative

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Object altMonitor
      The monitor synchronising the writers and alting reader
    • Constructor Summary

      Constructors 
      Constructor Description
      Alternative​(Guard[] guard)
      Construct an Alternative object operating on the Guard array of events.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int fairSelect()
      Returns the index of one of the ready guards.
      int fairSelect​(boolean[] preCondition)
      Returns the index of one of the ready guards whose preCondition index is true.
      int priSelect()
      Returns the index of one of the ready guards.
      int priSelect​(boolean[] preCondition)
      Returns the index of one of the ready guards whose preCondition index is true.
      int select()
      Returns the index of one of the ready guards.
      int select​(boolean[] preCondition)
      Returns the index of one of the ready guards whose preCondition index is true.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • altMonitor

        protected java.lang.Object altMonitor
        The monitor synchronising the writers and alting reader
    • Method Detail

      • select

        public final int select()
        Returns the index of one of the ready guards. The method will block until one of the guards becomes ready. If more than one is ready, an arbitrary choice is made.
      • priSelect

        public final int priSelect()
        Returns the index of one of the ready guards. The method will block until one of the guards becomes ready. If more than one is ready, the one with the lowest index is selected.
      • fairSelect

        public final int fairSelect()
        Returns the index of one of the ready guards. The method will block until one of the guards becomes ready. Consequetive invocations will service the guards `fairly' in the case when many guards are always ready. Implementation note: the last guard serviced has the lowest priority next time around.
      • select

        public final int select​(boolean[] preCondition)
        Returns the index of one of the ready guards whose preCondition index is true. The method will block until one of these guards becomes ready. If more than one is ready, an arbitrary choice is made.

        Note: the length of the preCondition array must be the same as that of the array of guards with which this object was constructed.

        Parameters:
        preCondition - the guards from which to select
      • priSelect

        public final int priSelect​(boolean[] preCondition)
        Returns the index of one of the ready guards whose preCondition index is true. The method will block until one of these guards becomes ready. If more than one is ready, the one with the lowest index is selected.

        Note: the length of the preCondition array must be the same as that of the array of guards with which this object was constructed.

        Parameters:
        preCondition - the guards from which to select
      • fairSelect

        public final int fairSelect​(boolean[] preCondition)
        Returns the index of one of the ready guards whose preCondition index is true. The method will block until one of these guards becomes ready. Consequetive invocations will service the guards `fairly' in the case when many guards are always ready. Implementation note: the last guard serviced has the lowest priority next time around.

        Note: the length of the preCondition array must be the same as that of the array of guards with which this object was constructed.

        Parameters:
        preCondition - the guards from which to select