Created
February 11, 2016 09:43
-
-
Save maxweber/6d9d1a630884f0376487 to your computer and use it in GitHub Desktop.
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 io-map | |
([number-of-threads f seq] | |
(let [executor (java.util.concurrent.Executors/newFixedThreadPool number-of-threads) | |
results (.invokeAll executor (map (fn [x] #(f x)) seq)) | |
result (doall (map deref results))] | |
(.shutdown executor) | |
result)) | |
([f seq] (io-map 50 f seq))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment