BATCH-1409: rever previous change (faile dbuild unknown reason)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#Wed Sep 09 08:10:50 BST 2009
|
||||
#Sat Sep 19 10:54:53 BST 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.batch.repeat.support;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link ResultQueue} that throttles the number of
|
||||
@@ -32,21 +33,19 @@ public class ThrottleLimitResultQueue<T> implements ResultQueue<T> {
|
||||
private final BlockingQueue<T> results;
|
||||
|
||||
// Accumulation of dummy objects flagging expected results in the future.
|
||||
private volatile int waits = 0;
|
||||
private final Semaphore waits;
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
private volatile int count = 0;
|
||||
|
||||
private final int throttleLimit;
|
||||
|
||||
/**
|
||||
* @param throttleLimit the maximum number of results that can be expected
|
||||
* at any given time.
|
||||
*/
|
||||
public ThrottleLimitResultQueue(int throttleLimit) {
|
||||
this.throttleLimit = throttleLimit;
|
||||
results = new LinkedBlockingQueue<T>();
|
||||
waits = new Semaphore(throttleLimit);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
@@ -61,7 +60,7 @@ public class ThrottleLimitResultQueue<T> implements ResultQueue<T> {
|
||||
public boolean isExpecting() {
|
||||
// Base the decision about whether we expect more results on a
|
||||
// counter of the number of expected results actually collected.
|
||||
// Do not synchronize! Otherwise put and expect can deadlock.
|
||||
// Do not synchronize! Otherwise put and expect can deadlock.
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@@ -74,10 +73,7 @@ public class ThrottleLimitResultQueue<T> implements ResultQueue<T> {
|
||||
*/
|
||||
public void expect() throws InterruptedException {
|
||||
synchronized (lock) {
|
||||
while (waits >= throttleLimit) {
|
||||
lock.wait();
|
||||
}
|
||||
waits++;
|
||||
waits.acquire();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -88,12 +84,9 @@ public class ThrottleLimitResultQueue<T> implements ResultQueue<T> {
|
||||
}
|
||||
// There should be no need to block here, or to use offer()
|
||||
results.add(holder);
|
||||
// Take from the waits now to allow another result to
|
||||
// Take from the waits queue now to allow another result to
|
||||
// accumulate. But don't decrement the counter.
|
||||
synchronized (lock) {
|
||||
waits--;
|
||||
lock.notifyAll();
|
||||
}
|
||||
waits.release();
|
||||
}
|
||||
|
||||
public T take() throws NoSuchElementException, InterruptedException {
|
||||
|
||||
Reference in New Issue
Block a user