Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created March 26, 2011 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/888637 to your computer and use it in GitHub Desktop.
Save swannodette/888637 to your computer and use it in GitHub Desktop.
(ns subcont.core
(:import [java.util.concurrent RecursiveTask]))
(set! *warn-on-reflection* true)
(defn ^RecursiveTask recursive-task [f]
(proxy [RecursiveTask] []
(compute [] (f))))
(def ^RecursiveTask t (recursive-task (fn [] :foo)))
(.compute ^RecursiveTask t) ;; reflection here :(
(comment
(dotimes [_ 10]
(let [^RecursiveTask t (recursive-task (fn [] 'foo))]
(time
(dotimes [_ 1e6]
(.compute t)))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment