Class IOHub

    • Method Detail

      • acquire

        public ByteBuffer acquire​(int size)
        Borrow a buffer from the pool.
        Specified by:
        acquire in interface ByteBufferPool
        Parameters:
        size - The minimum size and initial limit of the buffer.
        Returns:
        the buffer.
      • release

        public void release​(ByteBuffer buffer)
        Returns a buffer to the pool.
        Specified by:
        release in interface ByteBufferPool
        Parameters:
        buffer - the buffer.
      • execute

        @OverrideMustInvoke
        public void execute​(@NonNull
                            Runnable task)
        Specified by:
        execute in interface Executor
      • executeOnSelector

        @OverrideMustInvoke
        public void executeOnSelector​(Runnable task)
        Executes the given task at some time in the future. The task will execute in the selector thread.
        Parameters:
        task - the runnable task
        Throws:
        RejectedExecutionException - if this task cannot be accepted for execution
        NullPointerException - if task is null
      • executeLater

        @OverrideMustInvoke
        public Future<?> executeLater​(Runnable task,
                                      long delay,
                                      TimeUnit units)
        Executes a task at a future point in time. The scheduling is handled by the selector thread, and as such this method should not be used for timing critical scheduling, rather it is intended to be used for things such as protocol timeouts.
        Parameters:
        task - the task.
        delay - the delay.
        units - the time units for the delay.
        Returns:
        a Future that completes when the task has run and can be used to cancel the execution.
        Throws:
        RejectedExecutionException - if this task cannot be accepted for execution
        NullPointerException - if task is null
      • isOpen

        @OverrideMustInvoke
        public boolean isOpen()
        Check if the hub is open.
        Returns:
        true if the hub is open.
      • addInterestAccept

        public final void addInterestAccept​(SelectionKey key)
        Reregister the provided key as interested in accepting connections.
        Parameters:
        key - the key.
      • removeInterestAccept

        public final void removeInterestAccept​(SelectionKey key)
        Reregister the provided key as no longer interested in accepting connections.
        Parameters:
        key - the key.
      • addInterestConnect

        public final void addInterestConnect​(SelectionKey key)
        Reregister the provided key as interested in the connection with a server being established.
        Parameters:
        key - the key.
      • removeInterestConnect

        public final void removeInterestConnect​(SelectionKey key)
        Reregister the provided key as no longer interested in the connection with a server being established.
        Parameters:
        key - the key.
      • addInterestRead

        public final void addInterestRead​(SelectionKey key)
        Reregister the provided key as interested in reading data.
        Parameters:
        key - the key.
      • removeInterestRead

        public final void removeInterestRead​(SelectionKey key)
        Reregister the provided key as no longer interested in reading data.
        Parameters:
        key - the key.
      • addInterestWrite

        public final void addInterestWrite​(SelectionKey key)
        Reregister the provided key as interested in writing data.
        Parameters:
        key - the key.
      • removeInterestWrite

        public final void removeInterestWrite​(SelectionKey key)
        Reregister the provided key as no longer interested in writing data.
        Parameters:
        key - the key.
      • register

        public final Future<SelectionKey> register​(SelectableChannel channel,
                                                   IOHubReadyListener listener,
                                                   boolean accept,
                                                   boolean connect,
                                                   boolean read,
                                                   boolean write)
        Register the SelectableChannel for the requested operations using the supplied IOHubReadyListener.
        Parameters:
        channel - the SelectableChannel to register.
        listener - the IOHubReadyListener to call when the requested operations are available.
        accept - true to initially register for accepting connections from clients.
        connect - true to initially register for connection established with server.
        read - true to initially register for reading data.
        write - true to initially register for writing data.
        Returns:
        the Future for the SelectionKey.
      • run

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public final void run()
        Specified by:
        run in interface Runnable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object