Module 
Package org.xnio

Class AbstractConvertingIoFuture<T,​D>

  • Type Parameters:
    T - the type of this future result
    D - the type of the delegate result
    All Implemented Interfaces:
    Cancellable, IoFuture<T>

    public abstract class AbstractConvertingIoFuture<T,​D>
    extends java.lang.Object
    implements IoFuture<T>
    An IoFuture implementation that wraps a different type of IoFuture. Used to create general wrappers that convert one channel type to another.
    • Field Detail

      • delegate

        protected final IoFuture<? extends D> delegate
        The delegate future result.
    • Constructor Detail

      • AbstractConvertingIoFuture

        protected AbstractConvertingIoFuture​(IoFuture<? extends D> delegate)
    • Method Detail

      • getDelegate

        protected IoFuture<? extends D> getDelegate()
      • cancel

        public IoFuture<T> cancel()
        Description copied from interface: IoFuture
        Cancel an operation. The actual cancel may be synchronous or asynchronous.
        Specified by:
        cancel in interface Cancellable
        Specified by:
        cancel in interface IoFuture<T>
        Returns:
        this instance
      • await

        public IoFuture.Status await​(long time,
                                     java.util.concurrent.TimeUnit timeUnit)
        Description copied from interface: IoFuture
        Wait for the operation to complete, with a timeout. This method will block until the status changes from IoFuture.Status.WAITING, or the given time elapses. If the time elapses before the operation is complete, IoFuture.Status.WAITING is returned.
        Specified by:
        await in interface IoFuture<T>
        Parameters:
        time - the amount of time to wait
        timeUnit - the time unit
        Returns:
        the new status, or IoFuture.Status.WAITING if the timeout expired
      • awaitInterruptibly

        public IoFuture.Status awaitInterruptibly()
                                           throws java.lang.InterruptedException
        Description copied from interface: IoFuture
        Wait for the operation to complete. This method will block until the status changes from IoFuture.Status.WAITING, or the current thread is interrupted.
        Specified by:
        awaitInterruptibly in interface IoFuture<T>
        Returns:
        the new status
        Throws:
        java.lang.InterruptedException - if the operation is interrupted
      • awaitInterruptibly

        public IoFuture.Status awaitInterruptibly​(long time,
                                                  java.util.concurrent.TimeUnit timeUnit)
                                           throws java.lang.InterruptedException
        Description copied from interface: IoFuture
        Wait for the operation to complete, with a timeout. This method will block until the status changes from IoFuture.Status.WAITING, the given time elapses, or the current thread is interrupted. If the time elapses before the operation is complete, IoFuture.Status.WAITING is returned.
        Specified by:
        awaitInterruptibly in interface IoFuture<T>
        Parameters:
        time - the amount of time to wait
        timeUnit - the time unit
        Returns:
        the new status, or IoFuture.Status.WAITING if the timeout expired
        Throws:
        java.lang.InterruptedException - if the operation is interrupted
      • getException

        public java.io.IOException getException()
                                         throws java.lang.IllegalStateException
        Description copied from interface: IoFuture
        Get the failure reason.
        Specified by:
        getException in interface IoFuture<T>
        Returns:
        the failure reason
        Throws:
        java.lang.IllegalStateException - if the operation did not fail
      • get

        public T get()
              throws java.io.IOException
        Description copied from interface: IoFuture
        Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown.
        Specified by:
        get in interface IoFuture<T>
        Returns:
        the result of the operation
        Throws:
        java.io.IOException - if the operation failed
      • getInterruptibly

        public T getInterruptibly()
                           throws java.io.IOException,
                                  java.lang.InterruptedException
        Description copied from interface: IoFuture
        Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown. If the current thread is interrupted while waiting, an exception is thrown.
        Specified by:
        getInterruptibly in interface IoFuture<T>
        Returns:
        the result of the operation
        Throws:
        java.io.IOException - if the operation failed
        java.lang.InterruptedException - if the operation is interrupted
      • convert

        protected abstract T convert​(D arg)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • addNotifier

        public <A> IoFuture<T> addNotifier​(IoFuture.Notifier<? super T,​A> notifier,
                                           A attachment)
        Description copied from interface: IoFuture
        Add a notifier to be called when this operation is complete. If the operation is already complete, the notifier is called immediately, possibly in the caller's thread. The given attachment is provided to the notifier.
        Specified by:
        addNotifier in interface IoFuture<T>
        Type Parameters:
        A - the attachment type
        Parameters:
        notifier - the notifier to be called
        attachment - the attachment to pass in to the notifier
        Returns:
        this instance