-
-
Save rschmukler/314b786206246c906caa6a2f99d731a7 to your computer and use it in GitHub Desktop.
Loom Lock
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 ppmap | |
[f coll] | |
(->> coll | |
(mapv | |
(fn [x] | |
(let [cf (java.util.concurrent.CompletableFuture.)] | |
(Thread/startVirtualThread | |
(bound-fn [] | |
(try | |
(.complete cf (f x)) | |
(catch Exception e | |
(.completeExceptionally cf e))))) | |
cf))) | |
(map deref))) | |
(let [n 4] | |
(->> (range n) | |
(ppmap | |
(fn [_] | |
(->> (range n) | |
(ppmap (fn [_] | |
(->> (range n) | |
(ppmap (fn [_] | |
(ppmap identity (range n)))) | |
(apply concat) | |
(into #{})))) | |
(apply concat) | |
(into #{})))) | |
(apply concat) | |
(into #{}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment