Package org.jcsp.util

Interface ChannelDataStore<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int EMPTY
      Indicates that the ChannelDataStore is empty -- it can accept only a put.
      static int FULL
      Indicates that the ChannelDataStore is full -- it can accept only a get.
      static int NONEMPTYFULL
      Indicates that the ChannelDataStore is neither empty nor full -- it can accept either a put or a get call.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Returns a new (and EMPTY) ChannelDataStore with the same creation parameters as this one.
      void endGet()
      Ends an extended read on the buffer.
      T get()
      Returns an Object from the ChannelDataStore.
      int getState()
      Returns the current state of the ChannelDataStore.
      void put​(T value)
      Puts a new Object into the ChannelDataStore.
      void removeAll()
      Deletes all items in the buffer, leaving it empty.
      T startGet()
      Begins an extended read on the buffer, returning the data for the extended read.
    • Field Detail

      • EMPTY

        static final int EMPTY
        Indicates that the ChannelDataStore is empty -- it can accept only a put.
        See Also:
        Constant Field Values
      • NONEMPTYFULL

        static final int NONEMPTYFULL
        Indicates that the ChannelDataStore is neither empty nor full -- it can accept either a put or a get call.
        See Also:
        Constant Field Values
      • FULL

        static final int FULL
        Indicates that the ChannelDataStore is full -- it can accept only a get.
        See Also:
        Constant Field Values
    • Method Detail

      • getState

        int getState()
        Returns the current state of the ChannelDataStore.
        Returns:
        the current state of the ChannelDataStore (EMPTY, NONEMPTYFULL or FULL)
      • put

        void put​(T value)
        Puts a new Object into the ChannelDataStore.

        Pre-condition: getState must not currently return FULL.

        Parameters:
        value - the Object to put into the ChannelDataStore
      • get

        T get()
        Returns an Object from the ChannelDataStore.

        Pre-condition: getState must not currently return EMPTY.

        Returns:
        an Object from the ChannelDataStore
      • startGet

        T startGet()
        Begins an extended read on the buffer, returning the data for the extended read.

        Pre-condition: getState must not currently return EMPTY.

        The exact behaviour of this method depends on your buffer. When a process performs an extended rendezvous on a buffered channel, it will first call this method, then the endGet() method.

        A FIFO buffer would implement this method as returning the value from the front of the buffer and the next call would remove the value. An overflowing buffer would do the same.

        However, for an overwriting buffer it is more complex. Refer to the documentation for OverWritingBuffer.startGet() and OverWriteOldestBuffer.startGet() for details

        Returns:
        The object to be read from the channel at the beginning of the extended rendezvous
        See Also:
        endGet()
      • endGet

        void endGet()
        Ends an extended read on the buffer. The channels guarantee that this method will be called exactly once after each startGet call. During the period between startGet and endGet, it is possible that put will be called, but not get.
        See Also:
        startGet()
      • clone

        java.lang.Object clone()
        Returns a new (and EMPTY) ChannelDataStore with the same creation parameters as this one.

        Note: Only the size and structure of the ChannelDataStore should be cloned, not any stored data.

        Returns:
        the cloned instance of this ChannelDataStore.
      • removeAll

        void removeAll()
        Deletes all items in the buffer, leaving it empty.