Liking cljdoc? Tell your friends :D
All platforms.

co.multiply.quiescent.impl.race


raceclj/s

(race tasks)
(race tasks {:keys [tf release]})

Race multiple tasks, returning the first successful result.

When multiple tasks complete, the first non-exceptional result wins. Losing tasks are cancelled via cascade cancellation.

Options (second arity):

  • :tf - Transform function applied to winner's result
  • :release - Cleanup function for stateful resources from losing tasks (only called for non-nil results that weren't the winner)

Edge cases:

  • Empty tasks: Returns a task containing nil
  • Single task: Returns that task directly
  • All fail: Returns task with exception (single error or ex-info with :errors key)
  • All cancelled: Returns cancelled task

Note: Duplicate task instances are handled correctly - only one result is tracked per unique value.

Race multiple tasks, returning the first successful result.

When multiple tasks complete, the first non-exceptional result wins.
Losing tasks are cancelled via cascade cancellation.

Options (second arity):
- `:tf`      - Transform function applied to winner's result
- `:release` - Cleanup function for stateful resources from losing tasks
               (only called for non-nil results that weren't the winner)

Edge cases:
- Empty tasks: Returns a task containing nil
- Single task: Returns that task directly
- All fail: Returns task with exception (single error or ex-info with :errors key)
- All cancelled: Returns cancelled task

Note: Duplicate task instances are handled correctly - only one result
is tracked per unique value.
raw 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