public <T> void waitAbortable(Future<T> task) throws IOException, InterruptedException {
        while (!task.isDone() && !task.isCancelled()) {
            Char c = readIfAvailable();
            if (c != null && (c.asInteger() == Char.ABR ||
                              c.asInteger() == Char.ESC)) {
                task.cancel(true);
                throw new IOException("Aborted with '" + c.asString() + "'");
            }
            sleep(79L);
        }
    }
public < T > void waitAbortable ( Future < T > task ) throws IOException , InterruptedException { while ( ! task . isDone ( ) && ! task . isCancelled ( ) ) { Char c = readIfAvailable ( ) ; if ( c != null && ( c . asInteger ( ) == Char . ABR || c . asInteger ( ) == Char . ESC ) ) { task . cancel ( true ) ; throw new IOException ( "Aborted with '" + c . asString ( ) + "'" ) ; } sleep ( 79L ) ; } }
Wait for future task to be done or canceled. React to terminal
induced abort (ctrl-C) and cancel the task if so.

@param task The task to wait for.
@param <T> The task generic type.
@throws IOException On aborted or read failure.
@throws InterruptedException On thread interrupted.