Skip to content

Instantly share code, notes, and snippets.

@henryw374
Created June 8, 2022 08:18
Show Gist options
  • Save henryw374/4517d76b925d6da2134536fecf17dcb9 to your computer and use it in GitHub Desktop.
Save henryw374/4517d76b925d6da2134536fecf17dcb9 to your computer and use it in GitHub Desktop.
clojure executorservice concurrency testing
(ns same-thread-executor
"handy in unit tests to have things happen straight away"
(:import (java.util.concurrent ExecutorService Future)))
(defn executor []
(reify ExecutorService
(^Future submit [_ ^Callable f]
(let [r (f)]
(reify Future
(get [_] r))))))
(comment
@(.submit (executor) (fn [] "yay"))
;=> "yay"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment