|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.echarts.util.FIFOAcceptor
public final class FIFOAcceptor
A bit of a hack, but a useful hack nonetheless. Rather than merging messages from different sources into a single FIFO (or FIFO subclass) and having a thread wait on the FIFO, this class permits a thread to simultaneously wait on more than one FIFO at a time, akin to the Unix socket select() procedure, or Ada's selective accept construct. An acceptor may maintain strong references to its FIFO's but a FIFO maintains only weak references to its acceptors. This way, when a program releases all references to an acceptor it will be garbage collected even if the program still maintains references to fifo's referenced by the acceptor. An acceptor can only be used with local instances of FIFO's (i.e. FIFOImpl's), not with remote references to FIFO's. A note concerning the use of locks: synchronization is very tricky in this code since it is possible for a fifo to be accessing this object's state while this object is accessing the same fifo's state. We permit acquiring the fifo's lock followed by the acceptor's lock but not vice versa in order to prevent deadlock. To read or write the enabledFIFOsList, one must hold the acceptor's lock.
Field Summary | |
---|---|
static long |
serialVersionUID
|
Constructor Summary | |
---|---|
FIFOAcceptor()
|
Method Summary | |
---|---|
java.lang.Object |
accept()
Wait for an element to become available in one of the monitored FIFOs. |
java.lang.Object |
acceptNoBlock()
Check for an element to become available in one of the monitored FIFOs. |
void |
clearAcceptorAcceptor()
Clears value of AcceptorAcceptor for this FIFOAcceptor. |
void |
setAcceptorAcceptor(AcceptorAcceptor acceptorAcceptor)
Sets value of AcceptorAcceptor for this FIFOAcceptor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
Constructor Detail |
---|
public FIFOAcceptor()
Method Detail |
---|
public final java.lang.Object acceptNoBlock()
public final java.lang.Object accept() throws java.lang.InterruptedException
java.lang.InterruptedException
public final void setAcceptorAcceptor(AcceptorAcceptor acceptorAcceptor)
public final void clearAcceptorAcceptor()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |