public class MailboxSPSC<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 |
|---|
MailboxSPSC() |
MailboxSPSC(int initialSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMsgAvailableListener(EventSubscriber msgSub) |
void |
addSpaceAvailableListener(EventSubscriber spcSub) |
void |
clear() |
boolean |
fill(EventSubscriber eo,
T[] msg)
Non-blocking, nonpausing fill.
|
void |
fill(T[] msg)
Pausable fill Pause the caller until at least one message is available.
|
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
|
void |
put(T[] buf)
put a non-null messages from buffer in the mailbox, and pause the calling
task until all the messages put in the mailbox
|
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) |
void |
subscribe(boolean avail,
Task t,
boolean set) |
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 boolean fill(EventSubscriber eo, T[] msg)
eo - . If non-null, registers this observer and calls it with a
MessageAvailable event when a put() is done.public void put(T[] buf) throws Pausable
Pausablepublic 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 void clear()
public boolean isValid(Task t)
PauseReasonisValid in interface PauseReasonpublic void fill(T[] msg) throws Pausable
Pausable