Class BufferAddressedEnvelope<A extends SocketAddress,​T extends BufferAddressedEnvelope<A,​T>>

    • Constructor Detail

      • BufferAddressedEnvelope

        protected BufferAddressedEnvelope​(Buffer message,
                                          A recipient,
                                          A sender)
      • BufferAddressedEnvelope

        protected BufferAddressedEnvelope​(Buffer message,
                                          A recipient)
    • Method Detail

      • send

        public Send<T> send()
        Description copied from interface: Resource
        Send this object instance to another Thread, transferring the ownership to the recipient.

        The object must be in a state where it can be sent, which includes at least being accessible.

        When sent, this instance will immediately become inaccessible, as if by closing it. All attempts at accessing an object that has been sent, even if that object has not yet been received, should cause an exception to be thrown.

        Calling Resource.close() on an object that has been sent will have no effect, so this method is safe to call within a try-with-resources statement.

        Specified by:
        send in interface Resource<A extends SocketAddress>
      • replace

        public abstract T replace​(Buffer content)
        Create a new addressed envelope instance, that has the same recipient and sender as this one, but the given content.
        Parameters:
        content - The contents of the returned addressed envelope instance.
        Returns:
        An addressed envelope instance that has the same recipient and sender as this one, but the given content.
      • close

        public void close()
        Description copied from interface: Resource
        Close the resource, making it inaccessible.

        Note, this method is not thread-safe unless otherwise specified.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Resource<A extends SocketAddress>
      • isAccessible

        public boolean isAccessible()
        Description copied from interface: Resource
        Check if this object is accessible.
        Specified by:
        isAccessible in interface Resource<A extends SocketAddress>
        Returns:
        true if this object is still valid and can be accessed, otherwise false if, for instance, this object has been dropped/deallocated, or been sent elsewhere.