[Swift-commit] Cog update
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Sat Apr 28 20:25:03 CDT 2012
------------------------------------------------------------------------
r3379 | hategan | 2012-04-28 20:24:11 -0500 (Sat, 28 Apr 2012) | 1 line
use standard java blocking queue
------------------------------------------------------------------------
Index: modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/AbstractQueueProcessor.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/AbstractQueueProcessor.java (revision 3378)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/AbstractQueueProcessor.java (working copy)
@@ -9,69 +9,45 @@
*/
package org.globus.cog.abstraction.coaster.service.job.manager;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
import org.globus.cog.abstraction.interfaces.Task;
-import org.globus.cog.karajan.util.Queue;
public abstract class AbstractQueueProcessor extends Thread implements QueueProcessor {
- private final Queue q;
- private Queue.Cursor cursor;
+ private final BlockingQueue<AssociatedTask> q;
private boolean shutdownFlag;
private boolean wrap;
public AbstractQueueProcessor(String name) {
super(name);
- q = new Queue();
+ q = new LinkedBlockingQueue<AssociatedTask>();
}
public void enqueue(Task t) {
- synchronized (q) {
- if (shutdownFlag) {
- throw new IllegalStateException("Queue is shut down");
- }
- q.enqueue(new AssociatedTask(t));
- q.notifyAll();
+ if (shutdownFlag) {
+ throw new IllegalStateException("Queue is shut down");
}
+ q.offer(new AssociatedTask(t));
}
public void shutdown() {
- synchronized(q) {
- shutdownFlag = true;
- }
+ shutdownFlag = true;
}
protected boolean getShutdownFlag() {
return shutdownFlag;
}
- protected final Queue getQueue() {
- return q;
- }
-
protected final AssociatedTask take() throws InterruptedException {
- return (AssociatedTask) q.take();
+ return q.take();
}
protected final boolean hasWrapped() {
- synchronized (q) {
- return wrap;
- }
+ return wrap;
}
- protected final void remove() {
- synchronized (q) {
- if (cursor == null) {
- throw new IllegalThreadStateException(
- "next() was never called");
- }
- else {
- cursor.remove();
- }
- }
- }
-
protected int queuedTaskCount() {
- synchronized (q) {
- return q.size();
- }
+ return q.size();
}
}
More information about the Swift-commit
mailing list