When true (default), await throws if called from a platform thread.
Disable via:
-Dco.multiply.machine-latch.assert-virtual=false(alter-var-root #'*assert-virtual* (constantly false))(scoping [ml/*assert-virtual* false] ...)When true (default), `await` throws if called from a platform thread. Disable via: - JVM property: `-Dco.multiply.machine-latch.assert-virtual=false` - At runtime: `(alter-var-root #'*assert-virtual* (constantly false))` - Per-call: `(scoping [ml/*assert-virtual* false] ...)`
(at-or-past? latch target-state)Returns true if current state >= target-state in declared order. Non-blocking.
Returns true if current state >= `target-state` in declared order. Non-blocking.
(await latch target-state)CLJ: Block until state >= target-state. Returns true when reached.
CLJS: Returns a Promise that resolves to true when state >= target-state.
CLJ: Block until state >= `target-state`. Returns true when reached. CLJS: Returns a Promise that resolves to true when state >= `target-state`.
(await-dur latch target-state duration)Block until state >= target-state or timeout. Returns true if reached, false if timed out.
Must be called from a virtual thread (unless *assert-virtual* is false).
CLJ only.
Block until state >= `target-state` or timeout. Returns true if reached, false if timed out. Must be called from a virtual thread (unless `*assert-virtual*` is false). CLJ only.
(await-millis latch target-state milliseconds)CLJ: Block until state >= target-state or timeout. Returns true if reached, false if timed out.
CLJS: Returns a Promise that resolves to true or false.
CLJ: Block until state >= `target-state` or timeout. Returns true if reached, false if timed out. CLJS: Returns a Promise that resolves to true or false.
(get-state latch)Returns the current state keyword.
Returns the current state keyword.
(machine-latch-factory machine)Returns a factory fn that creates latches for this machine.
Machine spec:
{:states [:a :b :c ...] ; ordered from initial to terminal
:transitions {:action {from to} ; action with single from
:action2 {from1 to1, from2 to2}}} ; action with multiple froms
Pre-computes state->idx mapping and compiles transitions to use integers.
Each latch instance has its own state and waiter collection.
Returns a factory fn that creates latches for this machine.
Machine spec:
```clojure
{:states [:a :b :c ...] ; ordered from initial to terminal
:transitions {:action {from to} ; action with single from
:action2 {from1 to1, from2 to2}}} ; action with multiple froms
```
Pre-computes `state->idx` mapping and compiles transitions to use integers.
Each latch instance has its own state and waiter collection.(throw-on-platform-park! bool)Configure whether awaiting from a platform thread throws an exception.
When true (default), parking a platform thread raises IllegalStateException.
Set to false for testing or when platform thread parking is intentional.
CLJ only.
Configure whether awaiting from a platform thread throws an exception. When true (default), parking a platform thread raises `IllegalStateException`. Set to false for testing or when platform thread parking is intentional. CLJ only.
(transition! latch action)Atomically attempt to perform action. Returns true if succeeded, false otherwise. Fails if the action is not valid from the current state.
Atomically attempt to perform action. Returns true if succeeded, false otherwise. Fails if the action is not valid from the current state.
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 |