Internal concurrency primitives for channels.
Provides the Waiter and Commit abstractions used to build atomic multi-channel operations (alts!) and standard blocking channel operations on virtual threads.
Internal concurrency primitives for channels. Provides the Waiter and Commit abstractions used to build atomic multi-channel operations (alts!) and standard blocking channel operations on virtual threads.
(get-state commit)(set-state! commit val)(commit-val waiter val)Returns the value that should be set in the commit state upon success.
Returns the value that should be set in the commit state upon success.
(get-commit waiter)Returns the Commit object associated with this waiter.
Returns the Commit object associated with this waiter.
(get-value waiter)Returns the value associated with this waiter. Returns nil for take waiters.
Returns the value associated with this waiter. Returns nil for take waiters.
(new-commit)Creates a new Commit object for the current thread.
The Commit captures:
Returns: Commit instance with nil state, ready for park-and-wait
Creates a new Commit object for the current thread. The Commit captures: - Thread ID: Used for lock ordering in try-match! (deadlock prevention) - Thread reference: Used by LockSupport/unpark to wake this thread - State: Initially nil (pending), set to result when completed Returns: Commit instance with nil state, ready for park-and-wait
(park-and-wait commit timeout-ms)Parks the current virtual thread until the commit state is no longer nil.
Handles timeouts and Thread/interrupts correctly. If a timeout occurs or the thread is interrupted, attempts to lock the commit and set the state to :timeout or :interrupted respectively.
Returns the final state of the commit.
Parks the current virtual thread until the commit state is no longer nil. Handles timeouts and Thread/interrupts correctly. If a timeout occurs or the thread is interrupted, attempts to lock the commit and set the state to :timeout or :interrupted respectively. Returns the final state of the commit.
(poll! q)Extracts and removes the first element from a queue.
Wrapper around java.util.Queue/poll for type hinting. Returns nil if the queue is empty.
Used to atomically retrieve and remove waiters from takes/puts queues while holding the channel lock.
Extracts and removes the first element from a queue. Wrapper around java.util.Queue/poll for type hinting. Returns nil if the queue is empty. Used to atomically retrieve and remove waiters from takes/puts queues while holding the channel lock.
(try-commit! waiter val)Atomically attempt to fulfill a single waiter. Acquires the commit monitor lock. Returns true if successful.
Atomically attempt to fulfill a single waiter. Acquires the commit monitor lock. Returns true if successful.
(try-commit-fn! waiter val-fn)Atomically attempt to fulfill a single waiter with a value provided by a thunk. The thunk is ONLY evaluated if the commit is successfully locked and pending. Returns true if successful.
Atomically attempt to fulfill a single waiter with a value provided by a thunk. The thunk is ONLY evaluated if the commit is successfully locked and pending. Returns true if successful.
(try-match! w1 w2 val)Atomically attempt to fulfill two waiters simultaneously. Acquires both commit locks in ID order to prevent deadlocks. Returns true if BOTH commits were successfully fulfilled.
Atomically attempt to fulfill two waiters simultaneously. Acquires both commit locks in ID order to prevent deadlocks. Returns true if BOTH commits were successfully fulfilled.
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 |