X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Ffanfix_swing%2Fgui%2Futils%2FDelayWorker.java;h=6d630c5da9cf6b7c5443d4c814465275d7764f8d;hb=30c4d6ed834b52aa4ce4b252295c41b63375ecba;hp=19a9b5cd015723f5c95fb35bb7b128c44496b566;hpb=bdded4b57be305fc04a98860b3da8c89b662a9be;p=fanfix.git diff --git a/src/be/nikiroo/fanfix_swing/gui/utils/DelayWorker.java b/src/be/nikiroo/fanfix_swing/gui/utils/DelayWorker.java index 19a9b5c..6d630c5 100644 --- a/src/be/nikiroo/fanfix_swing/gui/utils/DelayWorker.java +++ b/src/be/nikiroo/fanfix_swing/gui/utils/DelayWorker.java @@ -1,26 +1,65 @@ package be.nikiroo.fanfix_swing.gui.utils; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; import java.util.Map; +import java.util.TreeSet; import javax.swing.SwingWorker; +/** + * This class helps you delay some graphical actions and execute the most recent + * ones when under contention. + *
+ * How does it work? + *
+ * Can be called even if already paused, will just do nothing in that + * context. + */ public void pause() { paused = true; } + /** + * Check if the {@link DelayWorker} is currently paused. + * + * @return TRUE if it is + */ public boolean isPaused() { return paused; } + /** + * Resume the system after a pause. + *
+ * Can be called even if already running, will just do nothing in that + * context. + */ public void resume() { synchronized (waiter) { paused = false; @@ -80,6 +166,13 @@ public class DelayWorker { } } + /** + * Stop the system. + *
+ * Note: this is final, you MUST NOT call {@link DelayWorker#start()}
+ * a second time (but see {@link DelayWorker#pause()} and
+ * {@link DelayWorker#resume()} instead).
+ */
public void stop() {
synchronized (waiter) {
cont = false;
@@ -87,13 +180,28 @@ public class DelayWorker {
}
}
+ /**
+ * Clear all the processes that were put on the queue but not yet scheduled
+ * to be executed -- note that it will still continue on the processes
+ * currently scheduled to run.
+ */
public void clear() {
synchronized (lazyEnCoursLock) {
lazyEnCours.clear();
+ wip.clear();
}
}
- public