Skip to content

Instantly share code, notes, and snippets.

@senior
Last active December 25, 2015 06:49
Show Gist options
  • Select an option

  • Save senior/6935402 to your computer and use it in GitHub Desktop.

Select an option

Save senior/6935402 to your computer and use it in GitHub Desktop.
with-redefs is global
(defn inc-it [x] (+ x 1))
(let [hand-off-queue (java.util.concurrent.SynchronousQueue.)
f1 (future-call
(fn []
(with-redefs [inc-it (fn [x] (- x))]
(.put hand-off-queue "foo")
(inc-it 10))))
f2 (future-call
(fn []
(.poll hand-off-queue 10 java.util.concurrent.TimeUnit/SECONDS)
(inc-it 10)))]
(println "f1 " @f1) ;; -> -10
(println "f2 " @f2)) ;; -> -10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment