@Override @SuppressWarnings("unchecked") <V extends Number,A>Future<V> implWrite(boolean isGatheringWrite,ByteBuffer src,ByteBuffer[] srcs,long timeout,TimeUnit unit,A attachment,CompletionHandler<V,? super A> handler){
  Invoker.GroupAndInvokeCount myGroupAndInvokeCount=Invoker.getGroupAndInvokeCount();
  boolean invokeDirect=Invoker.mayInvokeDirect(myGroupAndInvokeCount,port);
  boolean attemptWrite=(handler == null) || invokeDirect || !port.isFixedThreadPool();
  int n=IOStatus.UNAVAILABLE;
  Throwable exc=null;
  boolean pending=false;
  try {
    begin();
    if (attemptWrite) {
      if (isGatheringWrite) {
        n=(int)IOUtil.write(fd,srcs,nd);
      }
 else {
        n=IOUtil.write(fd,src,-1,nd);
      }
    }
    if (n == IOStatus.UNAVAILABLE) {
      PendingFuture<V,A> result=null;
synchronized (updateLock) {
        this.isGatheringWrite=isGatheringWrite;
        this.writeBuffer=src;
        this.writeBuffers=srcs;
        if (handler == null) {
          this.writeHandler=null;
          result=new PendingFuture<V,A>(this,OpType.WRITE);
          this.writeFuture=(PendingFuture<Number,Object>)result;
          this.writeAttachment=null;
        }
 else {
          this.writeHandler=(CompletionHandler<Number,Object>)handler;
          this.writeAttachment=attachment;
          this.writeFuture=null;
        }
        if (timeout > 0L) {
          this.writeTimer=port.schedule(writeTimeoutTask,timeout,unit);
        }
        this.writePending=true;
        updateEvents();
      }
      pending=true;
      return result;
    }
  }
 catch (  Throwable x) {
    if (x instanceof ClosedChannelException)     x=new AsynchronousCloseException();
    exc=x;
  }
 finally {
    if (!pending)     enableWriting();
    end();
  }
  Number result=(exc != null) ? null : (isGatheringWrite) ? (Number)Long.valueOf(n) : (Number)Integer.valueOf(n);
  if (handler != null) {
    if (invokeDirect) {
      Invoker.invokeDirect(myGroupAndInvokeCount,handler,attachment,(V)result,exc);
    }
 else {
      Invoker.invokeIndirectly(this,handler,attachment,(V)result,exc);
    }
    return null;
  }
 else {
    return CompletedFuture.withResult((V)result,exc);
  }
}

@ Override @ SuppressWarnings ( "unchecked" ) < V extends Number , A > Future < V > implWrite ( boolean isGatheringWrite , ByteBuffer src , ByteBuffer [ ] srcs , long timeout , TimeUnit unit , A attachment , CompletionHandler < V , ? super A > handler ) { Invoker . GroupAndInvokeCount myGroupAndInvokeCount = Invoker . getGroupAndInvokeCount ( ) ; boolean invokeDirect = Invoker . mayInvokeDirect ( myGroupAndInvokeCount , port ) ; boolean attemptWrite = ( handler == null ) || invokeDirect || ! port . isFixedThreadPool ( ) ; int n = IOStatus . UNAVAILABLE ; Throwable exc = null ; boolean pending = false ; try { begin ( ) ; if ( attemptWrite ) { if ( isGatheringWrite ) { n = ( int ) IOUtil . write ( fd , srcs , nd ) ; } else { n = IOUtil . write ( fd , src , - 1 , nd ) ; } } if ( n == IOStatus . UNAVAILABLE ) { PendingFuture < V , A > result = null ; synchronized ( updateLock ) { this . isGatheringWrite = isGatheringWrite ; this . writeBuffer = src ; this . writeBuffers = srcs ; if ( handler == null ) { this . writeHandler = null ; result = new PendingFuture < V , A > ( this , OpType . WRITE ) ; this . writeFuture = ( PendingFuture < Number , Object > ) result ; this . writeAttachment = null ; } else { this . writeHandler = ( CompletionHandler < Number , Object > ) handler ; this . writeAttachment = attachment ; this . writeFuture = null ; } if ( timeout > 0L ) { this . writeTimer = port . schedule ( writeTimeoutTask , timeout , unit ) ; } this . writePending = true ; updateEvents ( ) ; } pending = true ; return result ; } } catch ( Throwable x ) { if ( x instanceof ClosedChannelException ) x = new AsynchronousCloseException ( ) ; exc = x ; } finally { if ( ! pending ) enableWriting ( ) ; end ( ) ; } Number result = ( exc != null ) ? null : ( isGatheringWrite ) ? ( Number ) Long . valueOf ( n ) : ( Number ) Integer . valueOf ( n ) ; if ( handler != null ) { if ( invokeDirect ) { Invoker . invokeDirect ( myGroupAndInvokeCount , handler , attachment , ( V ) result , exc ) ; } else { Invoker . invokeIndirectly ( this , handler , attachment , ( V ) result , exc ) ; } return null ; } else { return CompletedFuture . withResult ( ( V ) result , exc ) ; } }
initiates a read or scattering read operation
