Created
March 19, 2010 16:41
-
-
Save Raynes/337795 to your computer and use it in GitHub Desktop.
This file contains 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 thunk-timeout [thunk] | |
(let [task (future-call thunk)] | |
(try | |
(.get task 1 TimeUnit/SECONDS) | |
(catch TimeoutException e | |
(.cancel task true) "Execution timed out!")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment