public interface MailboxReceiver
Mailbox
interface. This is used to dequeue letters. The mailbox returns letters
in the order by which they were enqueued. A mailbox should only be consumed by one thread at a time.Modifier and Type | Method and Description |
---|---|
boolean |
hasMail()
Returns
true if the mailbox contains mail. |
Runnable |
takeMail()
This method returns the oldest letter from the mailbox (head of queue) or blocks until a letter is available.
|
Optional<Runnable> |
tryTakeMail()
Returns an optional with either the oldest letter from the mailbox (head of queue) if the mailbox is not empty or
an empty optional otherwise.
|
void |
waitUntilHasMail()
This method blocks if the mailbox is empty until mail becomes available.
|
boolean hasMail()
true
if the mailbox contains mail.Optional<Runnable> tryTakeMail()
@Nonnull Runnable takeMail() throws InterruptedException
InterruptedException
- on interruption.void waitUntilHasMail() throws InterruptedException
InterruptedException
- on interruption.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.