Main process API.
This namespace provides the primary interface for working with processes:
Pids are Thread objects directly.
For pattern-matching receive macros, see loom-otp.process.match.
Main process API. This namespace provides the primary interface for working with processes: - spawn, spawn-link, spawn-opt for creating processes - self, send for current process and messaging - exit for termination - monitor, demonitor for unidirectional monitors - receive!, selective-receive! for receiving messages (function-based) - alive?, processes, process-info for introspection - register for name registration Pids are Thread objects directly. For pattern-matching receive macros, see loom-otp.process.match.
(alive?)(alive? pid)Check if process is alive. Returns true if alive, false if dead or not found. Returns false for non-Thread arguments.
Check if process is alive. Returns true if alive, false if dead or not found. Returns false for non-Thread arguments.
(process-info pid)Get information about a process. Returns nil for non-Thread or unknown pid.
Get information about a process. Returns nil for non-Thread or unknown pid.
(processes)Return list of all active process pids (Threads). Does not include processes that are past their cleanup time.
Return list of all active process pids (Threads). Does not include processes that are past their cleanup time.
(register name)(register name pid)Register name for pid. Throws if name already registered.
Register name for pid. Throws if name already registered.
Spawn a new process running (func & args). Returns pid (Thread).
Spawn a new process running (func & args). Returns pid (Thread).
(spawn! & body)Spawn a new process running body. Returns pid (Thread).
Usage: (spawn! (println "hello") (do-work))
Spawn a new process running body. Returns pid (Thread). Usage: (spawn! (println "hello") (do-work))
(spawn-async! & body)Spawn a new process asynchronously, body wrapped in fn. Returns a vfuture that resolves to pid (Thread).
Usage: (let [f (spawn-async! (do-work))] ... @f)
Spawn a new process asynchronously, body wrapped in fn. Returns a vfuture that resolves to pid (Thread). Usage: (let [f (spawn-async! (do-work))] ... @f)
Spawn a new process linked to current process. Returns pid (Thread).
Spawn a new process linked to current process. Returns pid (Thread).
(spawn-link! & body)Spawn a new process linked to current process, body wrapped in fn.
Usage: (spawn-link! (do-work))
Spawn a new process linked to current process, body wrapped in fn. Usage: (spawn-link! (do-work))
Spawn a new process monitored by current process. Returns [pid ref].
Spawn a new process monitored by current process. Returns [pid ref].
(spawn-monitor! & body)Spawn a new process monitored by current process, body wrapped in fn. Returns [pid ref].
Usage: (let [[pid ref] (spawn-monitor! (do-work))] ...)
Spawn a new process monitored by current process, body wrapped in fn. Returns [pid ref]. Usage: (let [[pid ref] (spawn-monitor! (do-work))] ...)
(spawn-opt {:keys [link monitor reg-name trap-exit async ex->reason-fn]}
func
&
args)Spawn with options. Returns pid, or [pid ref] if :monitor is true. If :async is true, returns a vfuture that resolves to pid (or [pid ref]).
Options:
Spawn with options. Returns pid, or [pid ref] if :monitor is true. If :async is true, returns a vfuture that resolves to pid (or [pid ref]). Options: - :link - if true, link to parent process - :monitor - if true, monitor child process (returns [pid ref]) - :reg-name - name to register the process as - :trap-exit - if true, convert exit signals to [:EXIT pid reason] messages - :async - if true, return vfuture instead of blocking for pid - :ex->reason-fn - function to convert exceptions to exit reasons
(spawn-opt! opts & body)Spawn with options, body wrapped in anonymous function.
Usage: (spawn-opt! {:trap-exit true} (do-something) (do-more))
Options: same as spawn-opt
Spawn with options, body wrapped in anonymous function.
Usage: (spawn-opt! {:trap-exit true} (do-something) (do-more))
Options: same as spawn-optSpawn a new process with trap-exit enabled. Returns pid (Thread).
Spawn a new process with trap-exit enabled. Returns pid (Thread).
(spawn-trap! & body)Spawn a new process with trap-exit enabled, body wrapped in fn.
Usage: (spawn-trap! (receive! [:EXIT pid reason] ...))
Spawn a new process with trap-exit enabled, body wrapped in fn. Usage: (spawn-trap! (receive! [:EXIT pid reason] ...))
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |