Liking cljdoc? Tell your friends :D

loom-otp.process

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.

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.
raw docstring

alive?clj

(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.
sourceraw docstring

demonitorclj

source

exitclj

source

monitorclj

source

process-infoclj

(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.
sourceraw docstring

processesclj

(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.
sourceraw docstring

receive!clj

source

registerclj

(register name)
(register name pid)

Register name for pid. Throws if name already registered.

Register name for pid. Throws if name already registered.
sourceraw docstring

selective-receive!clj

source

selfclj

source

sendclj

source

spawnclj

Spawn a new process running (func & args). Returns pid (Thread).

Spawn a new process running (func & args). Returns pid (Thread).
sourceraw docstring

spawn!cljmacro

(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))
sourceraw docstring

spawn-async!cljmacro

(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)
sourceraw docstring

Spawn a new process linked to current process. Returns pid (Thread).

Spawn a new process linked to current process. Returns pid (Thread).
sourceraw docstring

spawn-link!cljmacro

(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))
sourceraw docstring

spawn-monitorclj

Spawn a new process monitored by current process. Returns [pid ref].

Spawn a new process monitored by current process. Returns [pid ref].
sourceraw docstring

spawn-monitor!cljmacro

(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))] ...)
sourceraw docstring

spawn-optclj

(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:

  • :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 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
sourceraw docstring

spawn-opt!cljmacro

(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-opt
sourceraw docstring

spawn-trapclj

Spawn a new process with trap-exit enabled. Returns pid (Thread).

Spawn a new process with trap-exit enabled. Returns pid (Thread).
sourceraw docstring

spawn-trap!cljmacro

(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] ...))
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close