Liking cljdoc? Tell your friends :D

loom-otp.process.match

Pattern-matching receive macros using core.match.

This namespace provides macros for receiving messages with pattern matching:

  • receive! - FIFO receive with pattern matching
  • selective-receive! - selective receive with pattern matching

For function-based receive without pattern matching, see loom-otp.process.receive.

Pattern-matching receive macros using core.match.

This namespace provides macros for receiving messages with pattern matching:
- receive! - FIFO receive with pattern matching
- selective-receive! - selective receive with pattern matching

For function-based receive without pattern matching, see loom-otp.process.receive.
raw docstring

receive!cljmacro

(receive! & clauses)

Receive a message with pattern matching.

Usage: (receive! [:hello name] (println "Hello" name) [:add a b] (+ a b) (after 1000 :timeout))

The last clause can be (after timeout-ms expr) for timeout handling. Without an after clause and no matching message, throws an exception.

Message context is automatically merged into the process's context. EXIT signals (when trapping exits) are received as regular messages.

Receive a message with pattern matching.

Usage:
(receive!
  [:hello name] (println "Hello" name)
  [:add a b] (+ a b)
  (after 1000 :timeout))

The last clause can be (after timeout-ms expr) for timeout handling.
Without an after clause and no matching message, throws an exception.

Message context is automatically merged into the process's context.
EXIT signals (when trapping exits) are received as regular messages.
sourceraw docstring

selective-receive!cljmacro

(selective-receive! & clauses)

Receive first message matching any pattern, scanning the entire mailbox. Unlike receive!, this doesn't just take the first message - it finds the first message that matches any of the provided patterns.

Usage: (selective-receive! [:hello name] (println "Hello" name) [:add a b] (+ a b) (after 1000 :timeout))

The last clause can be (after timeout-ms expr) for timeout handling. Message context is automatically merged into the process's context.

Receive first message matching any pattern, scanning the entire mailbox.
Unlike receive!, this doesn't just take the first message - it finds
the first message that matches any of the provided patterns.

Usage:
(selective-receive!
  [:hello name] (println "Hello" name)
  [:add a b] (+ a b)
  (after 1000 :timeout))

The last clause can be (after timeout-ms expr) for timeout handling.
Message context is automatically merged into the process's context.
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