incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r960452 - in /sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl: JobHandler.java QuartzJobExecutor.java
Date Mon, 05 Jul 2010 06:03:40 GMT
Author: cziegeler
Date: Mon Jul  5 06:03:40 2010
New Revision: 960452

URL: http://svn.apache.org/viewvc?rev=960452&view=rev
Log:
SLING-1571 : Scheduler must use AtomicBoolean instead of volatile boolean for job-is-running
check

Modified:
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java
    sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java

Modified: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java?rev=960452&r1=960451&r2=960452&view=diff
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java
(original)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/JobHandler.java
Mon Jul  5 06:03:40 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.commons.scheduler.impl;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  * The job handler controls the invocation of a job
  * like parallel invocation and the number of times
@@ -25,10 +27,10 @@ public class JobHandler {
 
     public final boolean runConcurrently;
 
-    public volatile boolean isRunning;
+    public final AtomicBoolean isRunning;
 
     public JobHandler(final boolean runConcurrently) {
         this.runConcurrently = runConcurrently;
-        this.isRunning = false;
+        this.isRunning = new AtomicBoolean(false);
     }
 }
\ No newline at end of file

Modified: sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java?rev=960452&r1=960451&r2=960452&view=diff
==============================================================================
--- sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
(original)
+++ sling/trunk/bundles/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
Mon Jul  5 06:03:40 2010
@@ -44,10 +44,9 @@ public class QuartzJobExecutor implement
         final boolean canRunConcurrently = (handler == null ? true : handler.runConcurrently);
 
         if (!canRunConcurrently) {
-            if ( handler.isRunning ) {
+            if ( !handler.isRunning.compareAndSet(false, true) ) {
                 return;
             }
-            handler.isRunning = true;
         }
 
         final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
@@ -76,7 +75,7 @@ public class QuartzJobExecutor implement
             logger.error("Exception during job execution of " + job + " : " + t.getMessage(),
t);
         } finally {
             if (!canRunConcurrently) {
-                handler.isRunning = false;
+                handler.isRunning.set(false);
             }
         }
     }



Mime
View raw message