Skip to content

clojure.core.async/put!

View this page on ClojureDocs

Type: function Added: Clojure unknown Examples: 2 Runnable: 0
([port val] [port val fn1] [port val fn1 on-caller?])

Asynchronously puts a val into port, calling fn1 (if supplied) when complete, passing false iff port is already closed. nil values are not allowed. If on-caller? (default true) is true, and the put is immediately accepted, will call fn1 on calling thread.

fn1 may be run in a fixed-size dispatch thread pool and should not perform blocking IO, including core.async blocking ops (those that end in !!).

Returns true unless port is already closed.

Examples

by runexec on . May have evaluation errors.
by tomdl89 on . May have evaluation errors.

Note by hlship

The documentation here is somewhat out of date, the real documentation for more recent versions of core.async (0.1.346.0-17112a-alpha, at the time of this note) removes the bit about throwing when the channel is closed.

Instead, put! returns true unless the port is already closed, in which case false is returned.

An exception is thrown is you attempt to put! nil.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.