public long transferTo(
     final long count, final ByteBuffer throughBuffer, final StreamSinkChannel target)
     throws IOException {
   if (allAreSet(state, READ_SHUTDOWN) || count <= 0L) {
     return -1L;
   }
   final long res;
   if (Native.HAS_SPLICE && target instanceof NativeDescriptor) {
     res = Native.transfer(fd, count, throughBuffer, ((NativeDescriptor) target).fd);
     if (Native.EXTRA_TRACE) log.tracef("Splice(%d -> %s): %d", fd, target, res);
   } else {
     res = Conduits.transfer(this, count, throughBuffer, target);
   }
   if (res <= 0) state &= ~READ_READY;
   if (res > 0) checkReadTimeout(true);
   return res;
 }
 public long transferFrom(
     final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer)
     throws IOException {
   if (allAreSet(state, WRITE_SHUTDOWN)) {
     throw new ClosedChannelException();
   }
   if (count == 0L) return 0L;
   final long res;
   checkWriteTimeout(false);
   if (Native.HAS_SPLICE && source instanceof NativeDescriptor) {
     res =
         Native.testAndThrowRead(
             Native.transfer(((NativeDescriptor) source).fd, count, throughBuffer, fd));
     if (Native.EXTRA_TRACE) log.tracef("Splice(%s -> %d): %d", source, fd, res);
   } else {
     res = Conduits.transfer(source, count, throughBuffer, this);
   }
   if (res == 0) state &= ~WRITE_READY;
   if (res > 0) checkWriteTimeout(true);
   return res;
 }
Пример #3
0
 @Override
 public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException {
   return Conduits.writeFinalBasic(this, srcs, offset, length);
 }
Пример #4
0
 @Override
 public int writeFinal(ByteBuffer src) throws IOException {
   return Conduits.writeFinalBasic(this, src);
 }