You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/10/19 14:43:40 UTC
svn commit: r1024220 - in
/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues:
AbstractParallelJobQueue.java OrderedJobQueue.java
Author: cziegeler
Date: Tue Oct 19 12:43:40 2010
New Revision: 1024220
URL: http://svn.apache.org/viewvc?rev=1024220&view=rev
Log:
Use special lock objects for syncing
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java?rev=1024220&r1=1024219&r2=1024220&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java Tue Oct 19 12:43:40 2010
@@ -36,6 +36,8 @@ public abstract class AbstractParallelJo
/** The scheduler for rescheduling. */
private final Scheduler scheduler;
+ private final Object syncLock = new Object();
+
public AbstractParallelJobQueue(final String name,
final InternalQueueConfiguration config,
final EnvironmentComponent env,
@@ -65,13 +67,13 @@ public abstract class AbstractParallelJo
* This method is called if the queue is not ordered.
*/
private void acquireSlot() {
- synchronized ( this ) {
+ synchronized ( this.syncLock ) {
if ( jobCount >= this.configuration.getMaxParallel() ) {
this.isWaiting = true;
this.logger.debug("Job queue {} is processing {} jobs - waiting for a free slot.", this.queueName, jobCount);
while ( this.isWaiting ) {
try {
- this.wait();
+ this.syncLock.wait();
} catch (final InterruptedException e) {
this.ignoreException(e);
}
@@ -86,12 +88,12 @@ public abstract class AbstractParallelJo
* Free a slot when a job processing is finished.
*/
private void freeSlot() {
- synchronized ( this ) {
+ synchronized ( this.syncLock ) {
jobCount--;
if ( this.isWaiting ) {
this.logger.debug("Notifying job queue {} to continue processing.", this.queueName);
this.isWaiting = false;
- this.notify();
+ this.syncLock.notify();
}
}
}
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java?rev=1024220&r1=1024219&r2=1024220&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java Tue Oct 19 12:43:40 2010
@@ -49,6 +49,8 @@ public final class OrderedJobQueue exten
/** The queue. */
private final BlockingQueue<JobEvent> queue = new LinkedBlockingQueue<JobEvent>();
+ private final Object syncLock = new Object();
+
public OrderedJobQueue(final String name,
final InternalQueueConfiguration config,
final EnvironmentComponent env) {
@@ -97,12 +99,12 @@ public final class OrderedJobQueue exten
* This is called if the queue is ordered.
*/
private JobEvent waitForFinish() {
- synchronized ( this ) {
+ synchronized ( this.syncLock ) {
this.isWaiting = true;
this.logger.debug("Job queue {} is waiting for finish.", this.queueName);
while ( this.isWaiting ) {
try {
- this.wait();
+ this.syncLock.wait();
} catch (InterruptedException e) {
this.ignoreException(e);
}
@@ -145,8 +147,8 @@ public final class OrderedJobQueue exten
this.jobEvent = rescheduleInfo;
this.logger.debug("Notifying job queue {} to continue processing.", this.queueName);
this.isWaiting = false;
- synchronized ( this ) {
- this.notify();
+ synchronized ( this.syncLock ) {
+ this.syncLock.notify();
}
}