Create a gist now

Instantly share code, notes, and snippets.

(let [[sf st] (wrap (constantly 42))]
(def #^{:private true}s sf)
(def #^{:private true}f (wrap-with (fn [] (throw (Exception.))) st))
(def state st))
(dotimes [i 10]
(s))
(assert (= (ClosedState default-policy 0) @state))
(dotimes [i 5]
(try (f) (catch Exception e)))
(assert (= (ClosedState default-policy 5) @state))
(try (f) (catch Exception e))
(assert (= (class (OpenState default-policy 0)) (class @state)))
(Thread/sleep 5000)
(s)
(assert (= (ClosedState default-policy 0) @state))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment