1.3.0 permalink Arrow_down_16x16
  • (send a f & args)
Dispatch an action to an agent. Returns the agent immediately.
Subsequently, in a thread from a thread pool, 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 100))
    #'user/my-agent
    user=> @my-agent
    100
    
    ;; Note the following happens asynchronously in a thread
    ;; pool
    user=> (send my-agent + 100)
    #<Agent@5afc0f5: 200>
    
    ;; Assuming the addition has completed the value will
    ;; now be updated when we look at it.
    user=> @my-agent
    200
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:1876 top

(defn send
  "Dispatch an action to an agent. Returns the agent immediately.
  Subsequently, in a thread from a thread pool, 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 false))
Vars in clojure.core/send:
Used in 0 other vars

Comments top

No comments for send. Log in to add a comment.