Package com.mackenziehigh.cascade
Class Cascade.ArrayDequeMailbox<I>
java.lang.Object
com.mackenziehigh.cascade.Cascade.ArrayDequeMailbox<I>
- Type Parameters:
I
- is the type of messages that will be stored in the mailbox.
- All Implemented Interfaces:
Cascade.Stage.Actor.Mailbox<I>
- Enclosing interface:
- Cascade
public static final class Cascade.ArrayDequeMailbox<I>
extends Object
implements Cascade.Stage.Actor.Mailbox<I>
A
Mailbox
implementation based on a ArrayDeque
.-
Method Summary
-
Method Details
-
create
Create a new mailbox.- Type Parameters:
I
- is the type of messages that will be stored in the mailbox.- Parameters:
initial
- is the initial size of the backing data-structure.capacity
- is the maximum number of messages that can be stored simultaneously.- Returns:
- the new mailbox.
-
offer
Add a message to the mailbox.Notice that this method is synchronized.
- Specified by:
offer
in interfaceCascade.Stage.Actor.Mailbox<I>
- Parameters:
message
- will be added to the mailbox, if possible.- Returns:
- true, only if the message was in-fact added to the mailbox.
-
poll
Remove a message from the mailbox.If any message is in the mailbox, then this method must return non-null. In other words, a mailbox cannot choose to delay the removal of a message by forcing the caller to call this method again at a later time.
A mailbox can choose to unilaterally drop messages. In other words, a message that was successfully
offer()
-ed to this mailbox may never be returned bypoll()
, at the sole discretion of the mailbox itself.Notice that this method is synchronized.
- Specified by:
poll
in interfaceCascade.Stage.Actor.Mailbox<I>
- Returns:
- the message that was removed, or null, if no message was available.
-