Interface CloseableChannel

    • Method Summary

      Modifier and Type Method Description
      void addCloseListener​(ActionListener<java.lang.Void> listener)
      Adds a listener that will be executed when the channel is closed.
      static void blockOnFutures​(java.util.List<ActionFuture<java.lang.Void>> futures)  
      void close()
      Closes the channel.
      static <C extends CloseableChannel>
      void
      closeChannel​(C channel)
      Closes the channel without blocking.
      static <C extends CloseableChannel>
      void
      closeChannel​(C channel, boolean blocking)
      Closes the channel.
      static <C extends CloseableChannel>
      void
      closeChannels​(java.util.List<C> channels, boolean blocking)
      Closes the channels.
      boolean isOpen()
      Indicates whether a channel is currently open
    • Method Detail

      • close

        void close()
        Closes the channel. For most implementations, this will be be an asynchronous process. For this reason, this method does not throw IOException There is no guarantee that the channel will be closed when this method returns. Use the addCloseListener(ActionListener) method to implement logic that depends on knowing when the channel is closed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • addCloseListener

        void addCloseListener​(ActionListener<java.lang.Void> listener)
        Adds a listener that will be executed when the channel is closed. If the channel is still open when this listener is added, the listener will be executed by the thread that eventually closes the channel. If the channel is already closed when the listener is added the listener will immediately be executed by the thread that is attempting to add the listener.
        Parameters:
        listener - to be executed
      • isOpen

        boolean isOpen()
        Indicates whether a channel is currently open
        Returns:
        boolean indicating if channel is open
      • closeChannel

        static <C extends CloseableChannel> void closeChannel​(C channel)
        Closes the channel without blocking.
        Parameters:
        channel - to close
      • closeChannel

        static <C extends CloseableChannel> void closeChannel​(C channel,
                                                              boolean blocking)
        Closes the channel.
        Parameters:
        channel - to close
        blocking - indicates if we should block on channel close
      • closeChannels

        static <C extends CloseableChannel> void closeChannels​(java.util.List<C> channels,
                                                               boolean blocking)
        Closes the channels.
        Parameters:
        channels - to close
        blocking - indicates if we should block on channel close
      • blockOnFutures

        static void blockOnFutures​(java.util.List<ActionFuture<java.lang.Void>> futures)