summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/util
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-16 15:10:00 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-16 15:10:00 +0100
commit9742d69c56ef0866ca8b22696746b756e0670c81 (patch)
treed0d48ec970bec832ee669ea47d2ee8de4e8a5da3 /same/src/main/java/com/orbekk/util
parentc8274d3622d68e020de899c4e16c0a4ccb94db12 (diff)
Add manual performWork() in WorkQueue for testing.
Diffstat (limited to 'same/src/main/java/com/orbekk/util')
-rw-r--r--same/src/main/java/com/orbekk/util/WorkQueue.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/same/src/main/java/com/orbekk/util/WorkQueue.java b/same/src/main/java/com/orbekk/util/WorkQueue.java
index 4eb54f5..2fb2c88 100644
--- a/same/src/main/java/com/orbekk/util/WorkQueue.java
+++ b/same/src/main/java/com/orbekk/util/WorkQueue.java
@@ -38,6 +38,18 @@ abstract public class WorkQueue<E> extends Thread implements List<E> {
* Called until the queue is empty.
*/
protected abstract void onChange();
+
+ /**
+ * Perform work until the queue is empty.
+ *
+ * Can be used for testing or for combining several WorkQueues in
+ * a single thread.
+ */
+ public synchronized void performWork() {
+ while (!isEmpty()) {
+ onChange();
+ }
+ }
@Override
public void run() {