Skip to content

Instantly share code, notes, and snippets.

@krukow
Created January 1, 2010 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krukow/267173 to your computer and use it in GitHub Desktop.
Save krukow/267173 to your computer and use it in GitHub Desktop.
(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