Package org.jcsp.net2

Class Net2AnyChannel<T>

    • Field Detail

      • actualChannel

        private final Net2OneChannel actualChannel
        The underlying Net2OneChannel that this object wraps around
      • mutex

        private final Mutex mutex
        A mutual exclusion lock, allowing only one process access to perform a read operation at a time
    • Constructor Detail

      • Net2AnyChannel

        private Net2AnyChannel​(Net2OneChannel chan)
        Constructor for Net2AnyChannel
        Parameters:
        chan - The underlying channel that this object will wrap around
    • Method Detail

      • create

        static <T2> Net2AnyChannel<T2> create​(int poisonImmunity,
                                              NetworkMessageFilter.FilterRx filter)
                                       throws JCSPNetworkException
        A static factory method to create a new Net2AnyChannel object
        Parameters:
        poisonImmunity - The immunity level of the channel
        filter - The filter used to convert an incoming byte array into an object
        Returns:
        A new Net2AnyChannel
        Throws:
        JCSPNetworkException - Thrown if there is a problem creating the underlying channel
      • create

        static <T2> Net2AnyChannel<T2> create​(int index,
                                              int poisonImmunity,
                                              NetworkMessageFilter.FilterRx filter)
                                       throws java.lang.IllegalArgumentException,
                                              JCSPNetworkException
        Static factory method for creating a new instance of Net2AnyChannel, given a particular index
        Parameters:
        index - The index to create the channel with
        poisonImmunity - the immunity level of the channels
        filter - The filter used to convert the byte array back into an object
        Returns:
        A new Net2AnyChannel
        Throws:
        java.lang.IllegalArgumentException - Thrown if a channel with the given index already exists
        JCSPNetworkException - Thrown if something goes wrong during the creation of the underlying channel
      • poison

        public void poison​(int strength)
        Poisons the underlying channel
        Specified by:
        poison in interface Poisonable
        Parameters:
        strength - The strength of the poison
      • getLocation

        public NetLocation getLocation()
        Gets the channel location of this channel
        Specified by:
        getLocation in interface Networked
        Returns:
        Location of this channel
      • destroy

        public void destroy()
        Destroys the channel
        Specified by:
        destroy in interface Networked