Skip to content

Commit

Permalink
Slight readability/doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon Barrett committed Oct 30, 2014
1 parent a70d88d commit 41d3c73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/clj/com/climate/claypoole.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
When doing a pmap, Claypoole pushes input tasks into the threadpool. It
normally tries to keep the threadpool full, plus it adds a buffer of size
nthreads. If it can't find out the number of thread in the threadpool, it
nthreads. If it can't find out the number of threads in the threadpool, it
just tries to keep *default-pmap-buffer* tasks in the pool."
200)

Expand Down Expand Up @@ -278,17 +278,17 @@
`(future-call ~pool (^{:once true} fn future-body [] ~@body)))

(defn- make-canceller
"Creates a function to cancel a bunch of futures."
[future-reader]
"Creates a function to cancel a pmap."
[driver]
(let [first-already-cancelled (atom Long/MAX_VALUE)]
(fn [i later-tasks]
(let [cancel-end @first-already-cancelled]
;; Don't re-kill futures we've already zapped to prevent an O(n^2)
;; explosion.
(when (< i cancel-end)
(swap! first-already-cancelled min i)
;; Kill the future reader.
(future-cancel future-reader)
;; Kill the pmap driver thread.
(future-cancel driver)
;; Stop the tasks above i before cancel-end.
(doseq [f (->> later-tasks rest (take (- cancel-end i)))]
(future-cancel f)))))))
Expand Down
4 changes: 2 additions & 2 deletions src/clj/com/climate/claypoole/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@
nil))

;; Queue-seq needs a unique item that, when seen in a queue, indicates that the
;; sequence has ended. It uses this private object, and uses identical? to
;; check against this object's (unique) memory address.
;; sequence has ended. It uses the private object end-marker, and uses
;; identical? to check against this object's (unique) memory address.
(let [end-marker (Object.)]

(defn- queue-reader
Expand Down

0 comments on commit 41d3c73

Please sign in to comment.