/** * Tests whether the timeout has expired. */ public boolean isExpired() { return nanosLeft() <= 0; } }
/** * Returns how long is left before the timeout expires in the given time unit. * * @param unit the time unit of the return value * @return how long is left before the timeout expires in the given time unit. */ public long timeLeft(TimeUnit unit) { return unit.convert(nanosLeft(), TimeUnit.NANOSECONDS); }
/** * Blocks the current strand (either fiber or thread) until the given future completes - but no longer than the given timeout - and returns its result. * * @param future the future * @param timeout the method will not block for longer than the amount remaining in the {@link Timeout} * @return the future's result * @throws ExecutionException if the future's computation threw an exception * @throws TimeoutException if the timeout expired before the future completed * @throws InterruptedException if the current thread was interrupted while waiting */ public static <V> V get(CompletionStage<V> future, Timeout timeout) throws ExecutionException, InterruptedException, SuspendExecution, TimeoutException { return get(future, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public final boolean send(WebDataMessage message, Timeout timeout) throws SuspendExecution, InterruptedException { return send(message, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public long receiveLong(Timeout timeout) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { return receiveLong(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public boolean send(long message, Timeout timeout) throws SuspendExecution, InterruptedException { return send(message, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public boolean send(double message, Timeout timeout) throws SuspendExecution, InterruptedException { return send(message, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public boolean send(Message message, Timeout timeout) throws SuspendExecution, InterruptedException { return send(message, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
/** * Returns the next message from the mailbox. If no message is currently available, this method blocks until a message arrives, * but no longer than the given timeout. * * @param timeout the method will not block for longer than the amount remaining in the {@link Timeout} * @return a message sent to this actor, or {@code null} if the timeout has expired. * @throws InterruptedException */ @Override public final Message receive(Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public M receive(final Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public V receive(Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public double receiveDouble(Timeout timeout) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { return receiveDouble(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public T receive(Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
/** * Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout. * * @param timeout the method will not block for longer than the amount remaining in the {@link Timeout} * @return a message, or {@code null} if the channel has been closed and no more messages await (see {@link #isClosed()}), or if the timeout has expired. * @throws InterruptedException * @throws SuspendExecution */ default Message receive(Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public boolean send(final Message message, final Timeout timeout) throws SuspendExecution, InterruptedException { return send(message, timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public M receive(final Timeout timeout) throws SuspendExecution, InterruptedException { return timedReceive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public Message receive(Timeout timeout) throws SuspendExecution, InterruptedException { return receive(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public long receiveLong(Timeout timeout) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { return receiveLong(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public double receiveDouble(Timeout timeout) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { return receiveDouble(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }
@Override public int receiveInt(Timeout timeout) throws SuspendExecution, InterruptedException, TimeoutException, EOFException { return receiveInt(timeout.nanosLeft(), TimeUnit.NANOSECONDS); }