Author: doogie
Date: Mon Mar 15 07:22:47 2010
New Revision: 923095
URL:
http://svn.apache.org/viewvc?rev=923095&view=revLog:
Moved call to future.run to inside the main loop; as a side effect, this
causes us to finally reach full branch coverage.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=923095&r1=923094&r2=923095&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Mon Mar 15 07:22:47 2010
@@ -236,8 +236,12 @@ public abstract class TTLObject<T> imple
} else if (container.state == State.SET) {
nextContainer = container.valid(container.getValue());
} else if (container.state == State.REGENERATING || container.state == State.GENERATING || container.state == State.GENERATING_INITIAL) {
- if (container.state == State.REGENERATING && !container.future.isDone()) {
- return container.getValue();
+ if (!container.future.isDone()) {
+ if (container.state == State.GENERATING || container.state == State.GENERATING_INITIAL) {
+ container.future.run();
+ } else {
+ return container.getValue();
+ }
}
try {
try {
@@ -254,11 +258,9 @@ public abstract class TTLObject<T> imple
nextContainer = container.submit(container.getValue(), State.GENERATING);
}
} while (!objectAccessor.compareAndSet(this, container, nextContainer));
- if (nextContainer.state == State.GENERATING || nextContainer.state == State.GENERATING_INITIAL) {
- nextContainer.future.run();
- } else if (nextContainer.state == State.REGENERATING) {
+ if (nextContainer.state == State.REGENERATING) {
updateExecutor.submit(nextContainer.future);
- } else {
+ } else if (nextContainer.pulse != null) {
ExecutionPool.removePulse(container.pulse);
ExecutionPool.addPulse(nextContainer.pulse);
}