[hg] main-silver: #227776: check cancel status after acquiring d...

  • From: Svata Dedic < >
  • To:
  • Subject: [hg] main-silver: #227776: check cancel status after acquiring d...
  • Date: Fri, 29 Mar 2013 15:44:16 -0700

changeset 5611e519965d in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5611e519965d
description:
        #227776: check cancel status after acquiring document readlock

diffstat:

 csl.api/src/org/netbeans/modules/csl/editor/fold/GsfFoldManager.java |  28 
++++-----
 1 files changed, 13 insertions(+), 15 deletions(-)

diffs (77 lines):

diff --git 
a/csl.api/src/org/netbeans/modules/csl/editor/fold/GsfFoldManager.java 
b/csl.api/src/org/netbeans/modules/csl/editor/fold/GsfFoldManager.java
--- a/csl.api/src/org/netbeans/modules/csl/editor/fold/GsfFoldManager.java
+++ b/csl.api/src/org/netbeans/modules/csl/editor/fold/GsfFoldManager.java
@@ -181,7 +181,7 @@
     
     private FoldOperation operation;
     private FileObject    file;
-    private JavaElementFoldTask task;
+    private volatile JavaElementFoldTask task;
     
     private volatile Preferences prefs;
     
@@ -346,19 +346,16 @@
                 return;
             }
             
+            // pending: refactor!!
             if (mgrs instanceof GsfFoldManager) {
-                
SwingUtilities.invokeLater(((GsfFoldManager)mgrs).createCommit(
-                        folds, 
-                        initComment, imports, doc, 
info.getSnapshot().getSource()));
+                ((GsfFoldManager)mgrs).new CommitFolds(folds, 
+                        initComment, imports, doc, 
info.getSnapshot().getSource(), cancelled).run();
             } else {
-                SwingUtilities.invokeLater(new Runnable() {
                     Collection<GsfFoldManager> jefms = 
(Collection<GsfFoldManager>)mgrs;
-                    public void run() {
                         for (GsfFoldManager jefm : jefms) {
-                            jefm.createCommit(folds, initComment, imports, 
-                                    doc, 
info.getSnapshot().getSource()).run();
+                    jefm.new CommitFolds(folds, 
+                        initComment, imports, doc, 
info.getSnapshot().getSource(), cancelled).run();
                         }
-                }});
             }
             
             long endTime = System.currentTimeMillis();
@@ -589,10 +586,6 @@
 
     }
     
-    private Runnable createCommit(Collection<FoldInfo> folds, FoldInfo 
initComment, FoldInfo imports, Document d, Source s) {
-        return new CommitFolds(folds, initComment, imports, d, s);
-    }
-    
     private class CommitFolds implements Runnable {
         private final Document scannedDocument;
         private Source  scanSource;
@@ -602,13 +595,16 @@
         private long startTime;
         private FoldInfo    initComment;
         private FoldInfo    imports;
+        private final AtomicBoolean cancel;
         
-        public CommitFolds(Collection<FoldInfo> infos, FoldInfo initComment, 
FoldInfo imports, Document scannedDocument, Source s) {
+        public CommitFolds(Collection<FoldInfo> infos, FoldInfo initComment, 
FoldInfo imports, Document scannedDocument, Source s,
+                AtomicBoolean cancel) {
             this.infos = infos;
             this.initComment = initComment;
             this.imports = imports;
             this.scannedDocument = scannedDocument;
             this.scanSource = s;
+            this.cancel = cancel;
         }
         
         /**
@@ -631,7 +627,9 @@
                 
                 return;
             }
-            
+            if (cancel.get()) {
+                return;
+            }
             operation.getHierarchy().lock();
             if (task == null) {
                 return;

[hg] main-silver: #227776: check cancel status after acquiring d...

Svata Dedic 03/29/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close