public class MailboxMPSC<T> extends java.lang.Object implements PauseReason, EventPublisher
| Modifier and Type | Field and Description |
|---|---|
static Event |
messageAvailable |
static int |
MSG_AVAILABLE |
static int |
SPACE_AVAILABLE |
static Event |
spaceAvailble |
static int |
TIMED_OUT |
static Event |
timedOut |
| Constructor and Description |
|---|
MailboxMPSC() |
MailboxMPSC(int initialSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMsgAvailableListener(EventSubscriber msgSub) |
void |
addSpaceAvailableListener(EventSubscriber spcSub) |
void |
fill(T[] msg) |
T |
get() |
T |
get(EventSubscriber eo)
Non-blocking, nonpausing get.
|
T |
get(long timeoutMillis) |
T |
getnb()
Get, don't pause or block.
|
boolean |
isValid(Task t)
True if the given task's reason for pausing is still valid.
|
void |
put(T msg)
put a non-null message in the mailbox, and pause the calling task until
the mailbox has space
|
boolean |
put(T msg,
EventSubscriber eo) |
boolean |
put(T msg,
int timeoutMillis)
put a non-null message in the mailbox, and pause the calling task for
timeoutMillis if the mailbox is full.
|
boolean |
putnb(T msg)
Attempt to put a message, and return true if successful.
|
void |
removeMsgAvailableListener(EventSubscriber msgSub) |
void |
removeSpaceAvailableListener(EventSubscriber spcSub) |
java.lang.String |
toString() |
public static final int SPACE_AVAILABLE
public static final int MSG_AVAILABLE
public static final int TIMED_OUT
public static final Event spaceAvailble
public static final Event messageAvailable
public static final Event timedOut
public T get(EventSubscriber eo)
eo - . If non-null, registers this observer and calls it with a
MessageAvailable event when a put() is done.public boolean put(T msg, EventSubscriber eo)
public T getnb()
public T get(long timeoutMillis) throws Pausable
Pausablepublic boolean putnb(T msg)
public void addSpaceAvailableListener(EventSubscriber spcSub)
public void removeSpaceAvailableListener(EventSubscriber spcSub)
public void addMsgAvailableListener(EventSubscriber msgSub)
public void removeMsgAvailableListener(EventSubscriber msgSub)
public void put(T msg) throws Pausable
Pausablepublic boolean put(T msg, int timeoutMillis) throws Pausable
Pausablepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isValid(Task t)
PauseReasonisValid in interface PauseReasonpublic void fill(T[] msg)