(defn off
"Computes a lazy-seq in another (dedicated) thread."
[s]
(let [ex (. java.util.concurrent.Executors newSingleThreadExecutor)]
((fn this [s]
(if s
(let [future-rest (java.util.concurrent.FutureTask. #(rest s))]
(.execute ex future-rest)
(lazy-cons (first s) (this (.get future-rest))))
(.shutdown ex))) s)))
Monday, June 23, 2008
Lazier than lazy
This post has moved,
go to its new location
If you can't put off what you have to do, ask someone else to do it for you.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment