VCS: kill local changes gathering (project level) thread
authorirengrig <Irina.Chernushina@jetbrains.com>
Sat, 27 Feb 2010 16:22:42 +0000 (19:22 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Sat, 27 Feb 2010 16:22:42 +0000 (19:22 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ExecutorWrapper.java

index ceb7567ad7eaa8f015f9ca196a9a05b98219f05b..10d0c96b0e7cd7b742bacbbba24533d3c4e1220a 100644 (file)
@@ -34,6 +34,7 @@ public class ExecutorWrapper {
   private final Object myLock;
   private boolean myInProgress;
   private Runnable myStopper;
+  private Thread myCurrentWorker;
   private AtomicSectionsAware myAtomicSectionsAware;
 
   protected ExecutorWrapper(final Project project, final String name) {
@@ -46,6 +47,9 @@ public class ExecutorWrapper {
       public void run() {
         synchronized (myLock) {
           myDisposeStarted = true;
+          if (myCurrentWorker != null) {
+            myCurrentWorker.interrupt();
+          }
           taskFinished();
         }
       }
@@ -72,6 +76,7 @@ public class ExecutorWrapper {
 
   private void taskFinished() {
     synchronized (myLock) {
+      myCurrentWorker = null;
       if (myInProgress) {
         myInProgress = false;
         mySemaphore.up();
@@ -93,6 +98,9 @@ public class ExecutorWrapper {
       }
       ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
         public void run() {
+          synchronized (myLock) {
+            myCurrentWorker = Thread.currentThread();
+          }
           try {
             runnable.consume(myAtomicSectionsAware);
           } finally {