Permalink
Browse files

added some stats functions

  • Loading branch information...
1 parent f799a79 commit 98eb79c0e2cadbae91bed96bfe079ffb18c8d7bc @amitrathore committed Mar 22, 2011
Showing with 13 additions and 0 deletions.
  1. +6 −0 src/org/rathore/amit/medusa/core.clj
  2. +7 −0 src/org/rathore/amit/medusa/utils.clj
@@ -73,8 +73,14 @@
(defn current-pool-size []
(.getPoolSize THREADPOOL))
+(defn max-pool-size []
+ (.getMaximumPoolSize THREADPOOL))
+
(defn completed-task-count []
(.getCompletedTaskCount THREADPOOL))
(defn futures-count []
(count @running-futures))
+
+(defn medusa-stats []
+ {:queued (number-of-queued-tasks) :current-threads (current-pool-size) :max-threads (max-pool-size) :completed (completed-task-count)})
@@ -2,3 +2,10 @@
(defn random-uuid []
(str (java.util.UUID/randomUUID)))
+
+(defn threadpool-factory [thread-name-prefix]
+ (proxy [java.util.concurrent.ThreadFactory] []
+ (newThread [r]
+ (let [t (Thread. r)]
+ (.setName t (str thread-name-prefix (random-uuid)))
+ t))))

0 comments on commit 98eb79c

Please sign in to comment.