Last active
December 25, 2015 06:49
-
-
Save senior/6935402 to your computer and use it in GitHub Desktop.
with-redefs is global
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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