1.3.0 permalink Arrow_down_16x16

send-off

clojure.core

  • (send-off a f & args)
Dispatch a potentially blocking action to an agent. Returns the
agent immediately. Subsequently, in a separate thread, the state of
the agent will be set to the value of:

(apply action-fn state-of-agent args)

1 Example top

  • user=> (def my-agent (agent ""))
    #'user/my-agent
    user=> @my-agent
    ""
    
    ;; Note the following happens asynchronously in a thread
    ;; pool
    user=> (send my-agent #(slurp %2) "file.txt")
    #<Agent@13c6641: "">
    
    ;; Assuming the action has been invoked the value will
    ;; now be updated when we look at it.
    user=> @my-agent
    "file contents"
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1887 top

(defn send-off
  "Dispatch a potentially blocking action to an agent. Returns the
  agent immediately. Subsequently, in a separate thread, the state of
  the agent will be set to the value of:

  (apply action-fn state-of-agent args)"
  {:added "1.0"
   :static true}
  [^clojure.lang.Agent a f & args]
  (.dispatch a (binding [*agent* a] (binding-conveyor-fn f)) args true))
Vars in clojure.core/send-off:
Used in 0 other vars

Comments top

1 comment(s) for send-off.

The example uses "send", this is supposed to be an example for "send-off".

Log in to add a comment.