Skip to content

Instantly share code, notes, and snippets.

Created January 1, 2010 17:47
What would you like to do?
(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]
(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)
(assert (= (ClosedState default-policy 0) @state))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment