simplify, reduce volatile write count

This commit is contained in:
Alexey Kudravtsev
2014-08-15 11:22:05 +04:00
parent 53d679f0a8
commit eb78c0fb6c
2 changed files with 1 additions and 4 deletions
@@ -46,7 +46,7 @@ public abstract class ProgressIndicatorProvider {
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY;
}
public static volatile boolean ourNeedToCheckCancel = false;
protected static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) {
@@ -63,7 +63,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable {
@Override
public void run() {
ourNeedToCheckCancel = true;
ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
}, 0, 10, TimeUnit.MILLISECONDS);
}
@@ -85,7 +84,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable {
if (ourLockedCheckCounter > 10) {
ourLockedCheckCounter = 0;
ourNeedToCheckCancel = true;
ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
}
else {
@@ -98,7 +96,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable {
public static void canceled() {
ourNeedToCheckCancel = true;
ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
private static class NonCancelableIndicator extends EmptyProgressIndicator implements NonCancelableSection {