Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-09-11 09:30:01 -0400
committerMichael Valenta2003-09-11 09:30:01 -0400
commitc90b3963f13ab3661b3724a5d7ad85393c5e9b04 (patch)
tree40f0be16d1189a08dd9c0b30405f7edcd9593a70
parent0c9650ee0d4906e51fdc06d18d942258359252c2 (diff)
downloadeclipse.platform.team-c90b3963f13ab3661b3724a5d7ad85393c5e9b04.tar.gz
eclipse.platform.team-c90b3963f13ab3661b3724a5d7ad85393c5e9b04.tar.xz
eclipse.platform.team-c90b3963f13ab3661b3724a5d7ad85393c5e9b04.zip
Now using a lock instead of a scheduling rule to guarentee that refreshes are serialized
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java35
1 files changed, 15 insertions, 20 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
index 35f8e84ca..1b836a48e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.jobs;
+import org.eclipse.core.internal.jobs.JobManager;
+import org.eclipse.core.internal.jobs.OrderedLock;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -18,7 +20,6 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.team.core.TeamException;
@@ -46,12 +47,12 @@ public class RefreshSubscriberJob extends WorkspaceJob {
/**
* If true a rescheduled refresh job should be retarted when cancelled
*/
- private boolean restartOnCancel = true;
+ /* internal use only */ boolean restartOnCancel = true;
/**
* The schedule delay used when rescheduling a completed job
*/
- private static long scheduleDelay = 20000; //5 /* minutes */ * (60 * 1000);
+ /* internal use only */ static long scheduleDelay = 20000; //5 /* minutes */ * (60 * 1000);
/**
* Time the job was run last in milliseconds.
@@ -59,28 +60,17 @@ public class RefreshSubscriberJob extends WorkspaceJob {
private long lastTimeRun = 0;
/**
+ * Lock to ensure that only one refresh is occuring at a particulr time
+ */
+ private OrderedLock lock = JobManager.getInstance().getLockManager().newLock();
+
+ /**
* The subscribers and roots to refresh. If these are changed when the job
* is running the job is cancelled.
*/
private IResource[] resources;
private TeamSubscriber subscriber;
- private class BatchSimilarSchedulingRule implements ISchedulingRule {
- public String id;
- public BatchSimilarSchedulingRule(String id) {
- this.id = id;
- }
- public boolean isConflicting(ISchedulingRule rule) {
- if(rule instanceof BatchSimilarSchedulingRule) {
- return ((BatchSimilarSchedulingRule)rule).id.equals(id);
- }
- return false;
- }
- public boolean contains(ISchedulingRule rule) {
- return isConflicting(rule);
- }
- }
-
public RefreshSubscriberJob(String name, IResource[] resources, TeamSubscriber subscriber) {
super(name);
@@ -88,7 +78,6 @@ public class RefreshSubscriberJob extends WorkspaceJob {
this.subscriber = subscriber;
setPriority(Job.DECORATE);
- setRule(new BatchSimilarSchedulingRule("org.eclipse.team.core.refreshsubscribers")); //$NON-NLS-1$
addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
@@ -131,6 +120,11 @@ public class RefreshSubscriberJob extends WorkspaceJob {
monitor.beginTask(getTaskName(subscriber, roots), 100);
try {
+ // Only allow one refresh job at a time
+ // NOTE: It would be cleaner if this was done by a scheduling
+ // rule but at the time of writting, it is not possible due to
+ // the scheduling rule containment rules.
+ lock.acquire();
lastTimeRun = System.currentTimeMillis();
if(monitor.isCanceled()) {
return Status.CANCEL_STATUS;
@@ -144,6 +138,7 @@ public class RefreshSubscriberJob extends WorkspaceJob {
} catch(OperationCanceledException e2) {
return Status.CANCEL_STATUS;
} finally {
+ lock.release();
monitor.done();
}
return status.isOK() ? Status.OK_STATUS : (IStatus) status;

Back to the top