Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv24341

Modified Files:
        ThreadPools.java 
Log Message:
javadoc, plus a way to link 'identifiers' to the tasks, because looking in the 
queue can be a bit uninformative


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util


Index: ThreadPools.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/ThreadPools.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ThreadPools.java    1 Aug 2008 20:17:18 -0000       1.15
+++ ThreadPools.java    1 Aug 2008 21:04:52 -0000       1.16
@@ -16,14 +16,40 @@
  * Generic MMBase Thread Pools
  *
  * @since MMBase 1.8
- * @author Michiel Meewissen
- * @version $Id: ThreadPools.java,v 1.15 2008/08/01 20:17:18 michiel Exp $
+ * @author Michiel Meeuwissen
+ * @version $Id: ThreadPools.java,v 1.16 2008/08/01 21:04:52 michiel Exp $
  */
 public abstract class ThreadPools {
     private static final Logger log = 
Logging.getLoggerInstance(ThreadPools.class);
 
+    private static Map<Future, String> identifiers = 
Collections.synchronizedMap(new WeakHashMap<Future, String>());
+
+    /**
+     * There is no way to identify the FutureTask objects returned in
+     * the getQueue methods of the executors.  This works around that.
+     * Used by admin pages. 
+     * @since MMBase-1.9
+     */
+    public static String identify(Future r, String s) {
+        return identifiers.put(r, s);
+    }
+    /**
+     * returns a identifier string for the given task.
+     * @since MMBase-1.9
+     */
+    public static String getString(Future r) {
+        String s = identifiers.get(r);
+        if (s == null) return "" + r;
+        return s;
+    }
+
     /**
-     * Generic Thread Pools which can be used by 'filters'.
+     * Generic Thread Pools which can be used by 'filters'. Filters
+     * are short living tasks. This is mainly used by [EMAIL PROTECTED]
+     * org.mmbase.util.transformers.ChainedCharTransformer} (and only
+     * when transforming a Reader).
+     * 
+     * Code performing a similar task could also use this thread pool.
      */
     public static final ExecutorService filterExecutor = 
Executors.newCachedThreadPool();
 
@@ -46,7 +72,10 @@
     }
 
     /**
-     * For jobs there are 'scheduled', and typically happen on larger 
time-scales.
+     * All kind of jobs that should happend in a seperat Thread can be
+     * executed by this executor. E.g. sending mail could be done by a
+     * jobs of this type.
+     * 
      */
     public static final ExecutorService jobsExecutor = new 
ThreadPoolExecutor(2, 10, 5 * 60 , TimeUnit.SECONDS, new 
ArrayBlockingQueue<Runnable>(200), new ThreadFactory() {
 
@@ -56,6 +85,11 @@
         });
 
     /**
+     * This executor is for repeating tasks. E.g. every running
+     * [EMAIL PROTECTED] org.mmbase.module.Module}  has a  [EMAIL PROTECTED]
+     * org.mmbase.module.Module#maintainance} which is scheduled to
+     * run every hour.
+     *
      * @since MMBase-1.9
      */
     public static final ScheduledExecutorService scheduler = new 
ScheduledThreadPoolExecutor(2, new ThreadFactory() {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to