Author: scabanovich
Date: 2010-06-02 10:35:00 -0400 (Wed, 02 Jun 2010)
New Revision: 22479
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
Log:
https://jira.jboss.org/browse/JBIDE-6374
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2010-06-02
09:43:22 UTC (rev 22478)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2010-06-02
14:35:00 UTC (rev 22479)
@@ -118,12 +118,18 @@
ids.add(runnable.getId());
list.add(runnable);
}
- if (getState() == Job.NONE) {
+ if (getState() == Job.NONE || !isRunning()) {
schedule(1000);
}
}
}
+ private boolean isRunning() {
+ synchronized(this) {
+ return running;
+ }
+ }
+
void addRunnableInternalWithPriority(XRunnable runnable) {
if (!isSuspended()) {
synchronized (this) {
@@ -132,19 +138,27 @@
ids.add(runnable.getId());
list.add(0, runnable);
}
- if (getState() == Job.NONE) {
+ if (getState() == Job.NONE || !isRunning()) {
schedule(0);
}
}
}
+
+ boolean running = false;
@Override
public IStatus runInWorkspace(IProgressMonitor monitor)
throws CoreException {
+ synchronized(this) {
+ running = true;
+ }
while(true) {
XRunnable r = null;
synchronized (this) {
- if(list.size() == 0) break;
+ if(list.size() == 0) {
+ running = false;
+ break;
+ }
r = list.remove(0);
}
// monitor.subTask(r.getId()) is irrelevant for system jobs
@@ -154,13 +168,13 @@
//Bundle b = Platform.getBundle("org.jboss.tools.common.model");
//state = b==null ? -1 : b.getState();
//if(state == Bundle.ACTIVE) {
+ synchronized (this) {
+ ids.remove(r.getId());
+ }
if (!isSuspended()) {
r.run();
}
//}
- synchronized (this) {
- ids.remove(r.getId());
- }
}
return Status.OK_STATUS;
}
@@ -173,4 +187,4 @@
XJob.suspended = suspended;
}
-}
+}
\ No newline at end of file