1.2.0 permalink Arrow_down_16x16

capture-and-send

clojure.contrib.agent-utils

  • (capture-and-send vars agent action & args)
Capture the current value of the specified vars and rebind
them on the agent thread before executing the action.

Example:
(capture-and-send [*out*] a f b c)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/agent_utils.clj:22 top

(defmacro capture-and-send
 "Capture the current value of the specified vars and rebind 
  them on the agent thread before executing the action.
  
  Example:
    (capture-and-send [*out*] a f b c)"
    
 [vars agent action & args]
  (let [locals (map #(gensym (name %)) vars)]
    `(let [~@(interleave locals vars)
           action# (fn [& args#]
                     (binding [~@(interleave vars locals)]
                       (apply ~action args#)))]
       (send ~agent action# ~@args))))
Vars in clojure.contrib.agent-utils/capture-and-send: agent defmacro interleave let apply binding concat fn list send seq vector
Used in 0 other vars

Comments top

No comments for capture-and-send. Log in to add a comment.