public class QueuedMailbox<Msg extends Serializable> extends UnicastRemoteObject
Modifier and Type | Field and Description |
---|---|
protected int |
capacity |
protected int |
depositBlocks |
protected boolean |
open |
protected LinkedList<Msg> |
queue |
ref
Modifier | Constructor and Description |
---|---|
protected |
QueuedMailbox(Class<Msg> msgClass,
int capacity)
A new QueuedMailbox with given CAPACITY carrying messages of type
MSGCLASS.
|
Modifier and Type | Method and Description |
---|---|
int |
capacity()
The capacity (see interface comment above) of THIS.
|
<T extends Serializable> |
checkType(Class<T> msgClass)
Returns THIS, assuming that THIS conveys messages of class MSGCLASS.
|
void |
close()
Short for close (0).
|
void |
close(long millis)
Performs a flush(MILLIS) and then invalidates THIS for all future
use, deleting all remaining messages.
|
static <Msg extends Serializable> |
create(Class<Msg> msgClass,
int capacity)
A new QueuedMailbox
|
static <Msg extends Serializable> |
create(int capacity)
A new QueuedMailbox with capacity () fixed at CAPACITY, with
no type checking.
|
void |
deposit(Msg msg)
Deposit MSG in this Mailbox.
|
boolean |
deposit(Msg msg,
long millis)
Deposit MSG in this Mailbox, if this can be done within approximately
MILLIS milliseconds.
|
protected void |
enqueue(Msg msg)
Place MSG at the end of the message queue.
|
boolean |
flush(long millis)
Wait for all queued messages to be received, or MILLIS milliseconds,
whichever comes first.
|
protected void |
forward(Msg msg,
long millis)
Perform forwarding of MSG to all recipients, waiting for up to
MILLIS milliseconds for each deposit to be accepted.
|
void |
forwardTo(List<Mailbox<Msg>> boxes)
Forward copies of all messages (including any already present) to BOXES
in the order received.
|
void |
forwardTo(Mailbox<Msg> box)
Forward copies of all messages (including any already present) to BOXES
in the order received.
|
boolean |
isClosed()
True iff THIS is closed.
|
boolean |
isForwarding()
True iff THIS is currently forwarding messages as a result of
forwardTo.
|
Class<Msg> |
messageType()
The (runtime) type of message sent through this box.
|
protected long |
myWait(long limit)
Wait for up to LIMIT milliseconds or the next notify or interrupt.
|
Msg |
receive()
Receive the next queued message in this Mailbox.
|
Msg |
receive(long millis)
Receive the next queued message in this Mailbox, if one is
available within MILLIS milliseconds.
|
void |
stopForwarding()
Stop forwarding copies of messages.
|
clone, exportObject, exportObject, exportObject, unexportObject
getClientHost, getLog, setLog
protected final LinkedList<Msg extends Serializable> queue
protected int capacity
protected boolean open
protected int depositBlocks
protected QueuedMailbox(Class<Msg> msgClass, int capacity) throws RemoteException
RemoteException
public static <Msg extends Serializable> QueuedMailbox<Msg> create(Class<Msg> msgClass, int capacity)
public static <Msg extends Serializable> QueuedMailbox<Msg> create(int capacity)
public void deposit(Msg msg) throws InterruptedException, RemoteException
InterruptedException
RemoteException
public boolean deposit(Msg msg, long millis) throws InterruptedException, RemoteException
InterruptedException
RemoteException
public Msg receive() throws InterruptedException
InterruptedException
public Msg receive(long millis) throws InterruptedException
InterruptedException
public void forwardTo(Mailbox<Msg> box) throws InterruptedException, RemoteException
InterruptedException
RemoteException
public void forwardTo(List<Mailbox<Msg>> boxes) throws InterruptedException, RemoteException
InterruptedException
RemoteException
public void stopForwarding()
public boolean flush(long millis) throws InterruptedException
InterruptedException
public void close(long millis) throws InterruptedException
InterruptedException
public void close() throws InterruptedException
InterruptedException
public boolean isForwarding()
public boolean isClosed()
public int capacity()
protected void enqueue(Msg msg)
protected void forward(Msg msg, long millis) throws RemoteException, InterruptedException
RemoteException
InterruptedException
protected long myWait(long limit) throws InterruptedException
InterruptedException
public Class<Msg> messageType()
Mailbox
messageType
in interface Mailbox<Msg extends Serializable>
public <T extends Serializable> Mailbox<T> checkType(Class<T> msgClass)
Mailbox
checkType
in interface Mailbox<Msg extends Serializable>