/[gzz]/gzz/gzz/client/AbstractUpdateManager.java
ViewVC logotype

Diff of /gzz/gzz/client/AbstractUpdateManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by tjl, Fri Jan 10 18:44:51 2003 UTC revision 1.27 by tjl, Sat Jan 11 11:37:57 2003 UTC
# Line 319  public static final String rcsid = "$Id$ Line 319  public static final String rcsid = "$Id$
319       */       */
320      protected abstract boolean handleEvents(boolean waitForEvent);      protected abstract boolean handleEvents(boolean waitForEvent);
321    
322        private PriorityQueue queue = new PriorityQueue();
323    
324        /** Run a given task in the main thread at some point
325         * in the future.
326         * @see gzz.util.Background#addTask
327         */
328        public void doWhenIdle(Runnable r, int priority) {
329            synchronized(queue) {
330                queue.add(r, priority);
331                queue.notifyAll();
332            }
333        }
334    
335      /** Do the background tasks that need to be done in      /** Do the background tasks that need to be done in
336       * the main thread.       * the main thread.
337       * Implementations overriding this method should also delegate!       * Implementations overriding this method should also delegate!
338       * @return true if something was done.       * @return true if something was done.
339       */       */
340      protected boolean doIdle() {      protected boolean doIdle() {
341            synchronized(queue) {
342                Runnable r = (Runnable)queue.getAndRemoveLowest();
343                if(r != null) {
344                    if(dbg) pa("Updmanager idle: run "+r);
345                    r.run();
346                    if(dbg) pa("Updmanager idle: finished  run "+r);
347                    return true;
348                }
349            }
350          return false;          return false;
351      }      }
352    

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26