|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.amino.utility.EliminationArray
public class EliminationArray
A global elimination array class for several data structures. It can be used to reducing number of modification to central data structure. The idea comes from following observation:
If two threads execute push() or pop() operation on a stack, there is no need to modify the stack at all. We can simply transfer object from push() to the pop() and both operations succeed.Two arrays are created to store two type of operations, which are inversion of each other. It can be used to stack, deque, and even list. The algorithm comes from following paper, but not exactly the same.
A Scalable Lock-free Stack Algorithm Danny Hendler Nir Shavit Lena Yerushalmi School of Computer Science Tel-Aviv University & School of Computer Science Tel-Aviv University Sun Microsystems Tel-Aviv University Tel Aviv, Israel 69978 Laboratories Tel Aviv, Israel 69978 hendlerd@post.tau.ac.il shanir@sun.com lenay@post.tau.ac.il
Constructor Summary | |
---|---|
EliminationArray(int arraySize)
Create an EliminationArray object with specified size. |
Method Summary | |
---|---|
void |
dump()
dump for debug. |
boolean |
tryAdd(java.lang.Object obj,
int backOff)
Try to add element without touching the central data structure. |
java.lang.Object |
tryRemove(int backOff)
Try to remove element without touching central data structure. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EliminationArray(int arraySize)
arraySize
- Size of internal arrayMethod Detail |
---|
public void dump()
public boolean tryAdd(java.lang.Object obj, int backOff) throws java.lang.InterruptedException
tryAdd
in interface IEliminationArray
obj
- the adding objectbackOff
- time in millisecond for sleeping if match haven't been found
immediately.
java.lang.InterruptedException
- throw exception if interruptedpublic java.lang.Object tryRemove(int backOff) throws java.lang.InterruptedException
tryRemove
in interface IEliminationArray
backOff
- time in millisecond for sleeping if match haven't been found
immediately.
java.lang.InterruptedException
- throw exception if be interrupted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |