|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.utils.IncubationQueue<T>
public class IncubationQueue<T>
IncubationQueue is ordered queue where objects are added in two phases; (a) as incubating, they are given queuing number, and as (b) hatched they become available to the consumer. Objects become consumable when they are hatch()ed. The order of incubation is maintained. Objects become consumable in the order they were incubate()ed. This class is synchronized and is multi-thread-safe.
Example: IncubationQueue q = new IncubationQueue(); q.incubate("a"); q.incubate("b"); q.incubate("c"); q.hatch("b"); q.removeNextHatchedIfAvailable(); // returns null q.hatch("a"); q.removeNextHatched(); // returns "a" q.removeNextHatched(); // returns "b" q.removeNextHatchedIfAvailable(); // returns null q.hatch("c"); q.removeNextHatched(); // returns "c"
| Constructor Summary | |
|---|---|
IncubationQueue()
Create new Incubation queue that compares with equals()/hashCode |
|
IncubationQueue(boolean identityComparison)
Create new Incubation queue |
|
| Method Summary | |
|---|---|
void |
clear()
clear. |
boolean |
contains(T o)
contains. |
T |
getNext()
getNext. |
T |
getNextHatched()
Get next hatched object, blocks if empty or unhatched |
T |
getNextHatchedIfAvailable()
Get next hatched object |
boolean |
hatch(T o)
Hatch incubating object o. |
void |
incubate(T o)
Add object to the queue |
boolean |
isEmpty()
isEmpty. |
boolean |
isHatched(T o)
isHatched. |
boolean |
isIncubating(T o)
isIncubating. |
Iterator<T> |
iterator()
Non-thread safe iterator. |
boolean |
nextIsHatched()
Is next object hatched |
T |
removeNextHatched()
Remove next hatched object. |
T |
removeNextHatchedIfAvailable()
Remove next hatched object if available |
T |
removeNextHatchedUninterruptibly()
Remove next hatched object. |
int |
size()
size. |
void |
waitUntilIncubated(T o)
waitUntilIncubated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IncubationQueue()
public IncubationQueue(boolean identityComparison)
identityComparison - if true objects are compared with ==, false compare with equals()/hashCode()| Method Detail |
|---|
public void incubate(T o)
o - object not null and not in queue
public boolean hatch(T o)
throws IllegalArgumentException
o - object not null
IllegalArgumentException - if o was not incubatingpublic T removeNextHatchedIfAvailable()
public T removeNextHatched()
throws InterruptedException
InterruptedException - if any.public T removeNextHatchedUninterruptibly()
public boolean nextIsHatched()
public T getNextHatchedIfAvailable()
public T getNextHatched()
throws InterruptedException
InterruptedException - if any.
public T getNext()
throws InterruptedException
getNext.
InterruptedException - if any.public boolean isEmpty()
isEmpty.
public void clear()
clear.
public int size()
size.
public Iterator<T> iterator()
public boolean contains(T o)
contains.
o - a T object.
public boolean isHatched(T o)
isHatched.
o - a T object.
public boolean isIncubating(T o)
isIncubating.
o - a T object.
public void waitUntilIncubated(T o)
throws InterruptedException
waitUntilIncubated.
o - a T object.
InterruptedException - if any.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||