Liking cljdoc? Tell your friends :D

loom-otp.otplike.process

Compatibility shim providing otplike.process API backed by loom-otp.

Key differences handled:

  • ! function for sending (vs loom-otp's send)
  • proc-fn, proc-defn macros (vs loom-otp's plain functions)
  • async/await!/await!! implemented via vfuture
  • Tuple returns [:ok pid] vs map {:ok pid}
  • receive!! variant (blocking) is same as receive! in virtual threads

This namespace does NOT modify loom-otp internals.

Compatibility shim providing otplike.process API backed by loom-otp.

Key differences handled:
- `!` function for sending (vs loom-otp's `send`)
- `proc-fn`, `proc-defn` macros (vs loom-otp's plain functions)
- `async`/`await!`/`await!!` implemented via vfuture
- Tuple returns [:ok pid] vs map {:ok pid}
- `receive!!` variant (blocking) is same as receive! in virtual threads

This namespace does NOT modify loom-otp internals.
raw docstring

!clj

(! dest message)

Send a message to dest (pid or registered name). Returns true if sent, false if not.

Send a message to dest (pid or registered name). Returns true if sent, false if not.
sourceraw docstring

alive?clj

(alive?)
(alive? pid)

Check if process is alive.

Check if process is alive.
sourceraw docstring

asynccljmacro

(async & body)

Execute body immediately and capture the result or exception. Returns an Async value that can be awaited.

The body runs synchronously on the calling thread. This maintains the single-thread-per-process model and allows async code to access the process mailbox.

NOTE: InterruptedException is NOT caught during execution - it needs to propagate to the spawn handler which checks the exit-reason set by exit signals.

Execute body immediately and capture the result or exception.
Returns an Async value that can be awaited.

The body runs synchronously on the calling thread. This maintains the 
single-thread-per-process model and allows async code to access 
the process mailbox.

NOTE: InterruptedException is NOT caught during execution - it needs 
to propagate to the spawn handler which checks the exit-reason set 
by exit signals.
sourceraw docstring

async-valueclj

(async-value value)

Wrap a value as an already-completed async.

Wrap a value as an already-completed async.
sourceraw docstring

async?clj

(async? x)

Returns true if x is an async value.

Returns true if x is an async value.
sourceraw docstring

await!cljmacro

(await! x)

Wait for async value and return result. Parks/blocks if needed.

Wait for async value and return result. Parks/blocks if needed.
sourceraw docstring

await!!clj

(await!! x)

Same as await! - blocks. In virtual threads there's no difference. Throws IllegalArgumentException if x is not an async value.

Same as await! - blocks. In virtual threads there's no difference.
Throws IllegalArgumentException if x is not an async value.
sourceraw docstring

await?!cljmacro

(await?! x)

If x is async, await it. Otherwise return x.

If x is async, await it. Otherwise return x.
sourceraw docstring

demonitorclj

(demonitor mref)
(demonitor mref {:keys [flush]})

Remove a monitor. With {:flush true}, removes pending DOWN messages. Throws when called not in process context, or mref is not a ref.

Remove a monitor. With {:flush true}, removes pending DOWN messages.
Throws when called not in process context, or mref is not a ref.
sourceraw docstring

ex->reasonclj

(ex->reason e)

Convert exception to exit reason. Uses util/stack-trace for otplike-compatible exception format. InterruptedException is converted to :killed.

Convert exception to exit reason.
Uses util/stack-trace for otplike-compatible exception format.
InterruptedException is converted to :killed.
sourceraw docstring

ex-catchcljmacro

(ex-catch expr)

Execute expr, return result or [:EXIT reason] on exception.

Execute expr, return result or [:EXIT reason] on exception.
sourceraw docstring

exitclj

(exit reason)
(exit pid reason)

Exit with reason, or send exit signal to pid with reason. Returns true if process is/was alive, false if already terminated.

Exit with reason, or send exit signal to pid with reason.
Returns true if process is/was alive, false if already terminated.
sourceraw docstring

flagclj

(flag flag-name value)

Set a process flag. Returns the old value. Currently supports :trap-exit.

Set a process flag. Returns the old value.
Currently supports :trap-exit.
sourceraw docstring

(link pid)

Create a bidirectional link between calling process and pid. Must be called from within a process context. If pid is terminated, sends [:EXIT pid :noproc] to self if trapping exits, otherwise causes self to exit.

Create a bidirectional link between calling process and pid.
Must be called from within a process context.
If pid is terminated, sends [:EXIT pid :noproc] to self if trapping exits,
otherwise causes self to exit.
sourceraw docstring

map-asyncclj

(map-async f async-val)

Apply f to the eventual value of async-val. Creates a new Async that will apply f after the original transformations. The new Async shares the same result atom.

Apply f to the eventual value of async-val.
Creates a new Async that will apply f after the original transformations.
The new Async shares the same result atom.
sourceraw docstring

monitorclj

(monitor pid-or-name)

Monitor a process. Returns a reference.

Monitor a process. Returns a reference.
sourceraw docstring

pid->strclj

(pid->str pid)

Convert pid to string representation.

Convert pid to string representation.
sourceraw docstring

pid?clj

(pid? x)

Returns true if x is a process identifier.

Returns true if x is a process identifier.
sourceraw docstring

proc-defncljmacro

(proc-defn fname doc-string? args & body)

Define a process function. Same as (def name (proc-fn ...))

Define a process function. Same as (def name (proc-fn ...))
sourceraw docstring

proc-defn-cljmacro

(proc-defn- fname & more)

Same as proc-defn but private.

Same as proc-defn but private.
sourceraw docstring

proc-fncljmacro

(proc-fn name-or-args & more)

Create a process function. Returns a function suitable for spawn.

Usage: (proc-fn [x y] (+ x y)) (proc-fn my-name [x] (do-something x))

In otplike this creates a TProcFn for go blocks. In loom-otp this creates a regular function.

Create a process function. Returns a function suitable for spawn.

Usage:
(proc-fn [x y] (+ x y))
(proc-fn my-name [x] (do-something x))

In otplike this creates a TProcFn for go blocks.
In loom-otp this creates a regular function.
sourceraw docstring

process-infoclj

(process-info pid)
(process-info pid items)

Get information about a process. Throws if pid is not a pid, or specified info-key doesn't exist.

Get information about a process.
Throws if pid is not a pid, or specified info-key doesn't exist.
sourceraw docstring

processesclj

(processes)

Return list of all process pids.

Return list of all process pids.
sourceraw docstring

receive!cljmacro

(receive! & clauses)

Receive a message with pattern matching. Supports (after timeout body) clause.

Receive a message with pattern matching.
Supports (after timeout body) clause.
sourceraw docstring

receive!!cljmacro

(receive!! & clauses)

Same as receive! - in virtual threads blocking is the same as parking.

Same as receive! - in virtual threads blocking is the same as parking.
sourceraw docstring

ref?clj

(ref? x)

Returns true if x is a reference.

Returns true if x is a reference.
sourceraw docstring

registeredclj

(registered)

Returns a set of all registered names.

Returns a set of all registered names.
sourceraw docstring

resolve-pidclj

(resolve-pid pid-or-name)

Resolve pid-or-name to a pid. Returns nil if not found.

Resolve pid-or-name to a pid. Returns nil if not found.
sourceraw docstring

selective-receive!cljmacro

(selective-receive! & clauses)

Selective receive with pattern matching. Scans mailbox for first matching message.

Selective receive with pattern matching.
Scans mailbox for first matching message.
sourceraw docstring

selfclj

(self)

Returns the process identifier of the calling process.

Returns the process identifier of the calling process.
sourceraw docstring

spawnclj

(spawn proc-func)
(spawn proc-func args)

Spawn a process running (proc-func & args).

Spawn a process running (proc-func & args).
sourceraw docstring

(spawn-link proc-func)
(spawn-link proc-func args)

Spawn a process linked to the calling process.

Spawn a process linked to the calling process.
sourceraw docstring

spawn-optclj

(spawn-opt proc-func opts)
(spawn-opt proc-func args opts)

Spawn a process with options. proc-func is a function (not proc-fn). Options: :flags {:trap-exit true}, :link true, :register name

Spawn a process with options.
proc-func is a function (not proc-fn).
Options: :flags {:trap-exit true}, :link true, :register name
sourceraw docstring

traceclj

(trace pred handler)

Set up tracing with predicate and handler.

Set up tracing with predicate and handler.
sourceraw docstring

(unlink pid)

Remove link between calling process and pid. Must be called from within a process context.

Remove link between calling process and pid.
Must be called from within a process context.
sourceraw docstring

untraceclj

(untrace)

Remove trace handler.

Remove trace handler.
sourceraw docstring

whereisclj

(whereis name)

Returns the pid registered under name, or nil.

Returns the pid registered under name, or nil.
sourceraw docstring

with-asynccljmacro

(with-async [binding async-expr] & body)

Transform async value with body. Body receives the resolved value.

Transform async value with body. Body receives the resolved value.
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