Ejemplo n.º 1
0
 @Override
 public boolean send(Message message, long timeout, TimeUnit unit)
     throws SuspendExecution, InterruptedException {
   if (message == null) throw new IllegalArgumentException("message is null");
   if (isSendClosed()) return true;
   if (xfer1(message, true, TIMED, unit.toNanos(timeout)) == null) return true;
   if (!Strand.interrupted()) return false;
   throw new InterruptedException();
 }
Ejemplo n.º 2
0
  protected Message receiveInternal(long timeout, TimeUnit unit)
      throws SuspendExecution, InterruptedException {
    if (receiveClosed) return null;

    Object m = xfer1(null, false, TIMED, unit.toNanos(timeout));
    if (m != null || !Strand.interrupted()) {
      if (m == CHANNEL_CLOSED) return closeValue();
      return (Message) m;
    }
    throw new InterruptedException();
  }