private void emitUntil(@Nonnegative int taskCountAllowed) throws IOException {
  try {
    while (emitQueue.size() > taskCountAllowed) {
      Future<byte[]> future=emitQueue.remove();
      byte[] toWrite=future.get();
      blockSizes.add(toWrite.length);
      out.write(toWrite);
    }
    tryEmit();
  }
 catch (  ExecutionException e) {
    throw new IOException(e);
  }
catch (  InterruptedException e) {
    throw new InterruptedIOException();
  }
}

private void emitUntil ( @ Nonnegative int taskCountAllowed ) throws IOException { try { while ( emitQueue . size ( ) > taskCountAllowed ) { Future < byte [ ] > future = emitQueue . remove ( ) ; byte [ ] toWrite = future . get ( ) ; blockSizes . add ( toWrite . length ) ; out . write ( toWrite ) ; } tryEmit ( ) ; } catch ( ExecutionException e ) { throw new IOException ( e ) ; } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } }
emits any opportunistically available blocks . furthermore , emits blocks until the number of executing tasks is less than taskcountallowed .
