Interface CloseableChannel

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
HttpChannel, HttpServerChannel, TcpChannel, TcpServerChannel

public interface CloseableChannel extends Closeable
  • Method Details

    • 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 AutoCloseable
      Specified by:
      close in interface Closeable
    • addCloseListener

      void addCloseListener(ActionListener<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(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(List<ActionFuture<Void>> futures)