1 11 package org.eclipse.jface.viewers.deferred; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 15 22 final class FastProgressReporter { 23 private IProgressMonitor monitor; 24 private volatile boolean canceled = false; 25 private int cancelCheck = 0; 26 34 private static int CANCEL_CHECK_PERIOD = 40; 35 36 39 public FastProgressReporter() { 40 } 41 42 48 public FastProgressReporter(IProgressMonitor monitor, int totalProgress) { 49 this.monitor = monitor; 50 canceled = monitor.isCanceled(); 52 } 53 54 117 122 public boolean isCanceled() { 123 if (monitor == null) { 124 return canceled; 125 } 126 127 cancelCheck++; 128 if (cancelCheck > CANCEL_CHECK_PERIOD) { 129 canceled = monitor.isCanceled(); 130 cancelCheck = 0; 131 } 132 return canceled; 133 } 134 135 138 public void cancel() { 139 canceled = true; 140 141 if (monitor == null) { 142 return; 143 } 144 monitor.setCanceled(true); 145 } 146 } 147 | Popular Tags |