java.nio.channels.ReadPendingException源码实例Demo

类java.nio.channels.ReadPendingException源码实例Demo

下面列出了java.nio.channels.ReadPendingException 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pgadba   文件: AsynchronousTlsChannelGroup.java
ReadOperation startRead(
    RegisteredSocket socket,
    ByteBufferSet buffer,
    long timeout, TimeUnit unit,
    LongConsumer onSuccess, Consumer<Throwable> onFailure)
    throws ReadPendingException {
  checkTerminated();
  Util.assertTrue(buffer.hasRemaining());
  waitForSocketRegistration(socket);
  ReadOperation op;
  socket.readLock.lock();
  try {
    if (socket.readOperation != null) {
      throw new ReadPendingException();
    }
    op = new ReadOperation(buffer, onSuccess, onFailure);
    /*
     * we do not try to outsmart the TLS state machine and register for both IO operations for each new socket
     * operation
     */
    socket.pendingOps.set(SelectionKey.OP_WRITE | SelectionKey.OP_READ);
    if (timeout != 0) {
      op.timeoutFuture = timeoutExecutor.schedule(() -> {
        boolean success = doCancelRead(socket, op);
        if (success) {
          op.onFailure.accept(new InterruptedByTimeoutException());
        }
      }, timeout, unit);
    }
    socket.readOperation = op;
  } finally {
    socket.readLock.unlock();
  }
  selector.wakeup();
  startedReads.increment();
  currentReads.increment();
  return op;
}
 
源代码2 项目: j2objc   文件: ReadPendingExceptionTest.java
/**
 * java.nio.channels.ReadPendingException#ReadPendingException()
 */
public void test_empty() {
    ReadPendingException e = new ReadPendingException();
    assertTrue(e instanceof IllegalStateException);
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
 
源代码3 项目: qpid-broker-j   文件: MarkableEndPoint.java
@Override
public void fillInterested(final Callback callback) throws ReadPendingException
{
    _underlying.fillInterested(callback);
}
 
源代码4 项目: tls-channel   文件: AsynchronousTlsChannelGroup.java
ReadOperation startRead(
    RegisteredSocket socket,
    ByteBufferSet buffer,
    long timeout,
    TimeUnit unit,
    LongConsumer onSuccess,
    Consumer<Throwable> onFailure)
    throws ReadPendingException {
  checkTerminated();
  Util.assertTrue(buffer.hasRemaining());
  waitForSocketRegistration(socket);
  ReadOperation op;
  socket.readLock.lock();
  try {
    if (socket.readOperation != null) {
      throw new ReadPendingException();
    }
    op = new ReadOperation(buffer, onSuccess, onFailure);
    /*
     * we do not try to outsmart the TLS state machine and register for both IO operations for each new socket
     * operation
     */
    socket.pendingOps.set(SelectionKey.OP_WRITE | SelectionKey.OP_READ);
    if (timeout != 0) {
      op.timeoutFuture =
          timeoutExecutor.schedule(
              () -> {
                boolean success = doCancelRead(socket, op);
                if (success) {
                  op.onFailure.accept(new InterruptedByTimeoutException());
                }
              },
              timeout,
              unit);
    }
    socket.readOperation = op;
  } finally {
    socket.readLock.unlock();
  }
  selector.wakeup();
  startedReads.increment();
  currentReads.increment();
  return op;
}