Skip to content

Instantly share code, notes, and snippets.

@amalloy
Forked from arohner/gist:ed2a1de1af8dc047c5f6
Created April 2, 2012 23:52
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 amalloy/b4774f8b8ed83657d3e0 to your computer and use it in GitHub Desktop.
Save amalloy/b4774f8b8ed83657d3e0 to your computer and use it in GitHub Desktop.
callable
(defn call* [pfn]
(let [v (-> pfn :v)]
(apply v (-> pfn :args))))
(defrecord SerializableFn [v args]
clojure.lang.IFn
(invoke [this]
(call* this))
(call [this] ;; j.u.c.Concurrent
(call* this))
(run [this] ;; j.l.Runnable
(call* this)))
(.call ^java.util.concurrent.Callable (user.SerializableFn. inc [1])) ;; 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment