Liking cljdoc? Tell your friends :D

csp-clj.channels.waiters

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

EOFclj

source

ICommitStatecljprotocol

get-stateclj

(get-state commit)

set-state!clj

(set-state! commit val)
source

IWaitercljprotocol

commit-valclj

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

(get-commit waiter)

Returns the Commit object associated with this waiter.

Returns the Commit object associated with this waiter.

get-valueclj

(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.
source

new-commitclj

(new-commit)

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

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

park-and-waitclj

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

poll!clj

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

PUT_FAILclj

source

try-commit!clj

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

try-commit-fn!clj

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

try-match!clj

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