Liking cljdoc? Tell your friends :D

halfling.task


attemptcljmacro

(attempt & body)

Safely runs a body in a try block and captures its outcome in a Result. In case of a success, the result will look like: {:status :success :value [<result of computation>]}

In case of a failure, the result will look like: {:status :failure :value [<throwable/exception object>]}

Safely runs a `body` in a `try` block
and captures its outcome in a `Result`.
In case of a success, the result will look like:
{:status :success
 :value  [<result of computation>]}

In case of a failure, the result will look like:
{:status :failure
 :value  [<throwable/exception object>]}
sourceraw docstring

broken?clj

(broken? task)

Returns true if task has been realised and failed, false otherwise. Note: Doesn't check if a task has been run. An un-run task is still considered to be realised.

Returns `true` if `task` has been realised and failed, `false` otherwise.
Note: Doesn't check if a task has been run.
An un-run task is still considered to be realised.
sourceraw docstring

const-futureclj

(const-future value)

Wraps a value in a completed Future object.

Wraps a value in a completed `Future` object.
sourceraw docstring

do-taskscljmacro

(do-tasks bindings & body)

A let-like construct that allows working with tasks as if they were successfully realised. Binds single tasks to names in a let-like fashion and considers the names as being the realised values of those tasks. In addition, it also supports non-task expressions. These will automatically be lifted to a task. Example: (do-tasks [a (task 1) _ (println a) b (task 2)] (+ a b))

As of 1.2.0 also supports syntax for recover and recover-as: (do-tasks [a (task 1) _ (println a) b (task 2) :recover #(.getMessage %)] (+ a b))

...

(do-tasks [a (task 1) _ (println a) b (task 2) :recover-as -1] (+ a b))

A `let`-like construct that allows working with
tasks as if they were successfully realised.
Binds single tasks to names in a `let`-like fashion and
considers the names as being the realised values of those tasks.
In addition, it also supports non-task expressions. These will
automatically be lifted to a `task`.
Example:
 (do-tasks [a (task 1)
            _ (println a)
            b (task 2)]
  (+ a b))

 As of 1.2.0 also supports syntax for `recover` and `recover-as`:
 (do-tasks [a (task 1)
            _ (println a)
            b (task 2)
            :recover #(.getMessage %)]
  (+ a b))

  ...

  (do-tasks [a (task 1)
             _ (println a)
             b (task 2)
             :recover-as -1]
   (+ a b))
sourceraw docstring

done?clj

(done? task)

Returns true if task has been realised, false otherwise. Note: Doesn't check if the task has been run. An un-run task is still considered to be realised. For both checks, take a look at executed?.

Returns `true` if `task` has been realised, `false` otherwise.
Note: Doesn't check if the task has been run.
An un-run task is still considered to be realised.
For both checks, take a look at `executed?`.
sourceraw docstring

executed?clj

(executed? task)

Returns true if task has been realised and run, false otherwise.

Returns `true` if `task` has been realised and run, `false` otherwise.
sourceraw docstring

failureclj

(failure message)

Given some string message, returns a realised failed task containing an error with the given message

Given some string `message`, returns a realised failed task containing an error with the given `message`
sourceraw docstring

failure-tclj

(failure-t throwable)

Given a proper error Throwable, returns a realised failed task containing it.

Given a proper error `Throwable`, returns a realised failed task containing it.
sourceraw docstring

fulfilled?clj

(fulfilled? task)

Returns true if task has been realised and was successful, false otherwise. Note: Doesn't check if a task has been run. An un-run task is still considered to be realised.

Returns `true` if `task` has been realised and was successful, `false` otherwise.
Note: Doesn't check if a task has been run.
An un-run task is still considered to be realised.
sourceraw docstring

get!clj

(get! task)
(get! task timeout else)

Returns the value of task. Blocks task until it is realised. If task is successful, returns its value. If it is failed, returns a collection of Throwable error objects. Note: Doesn't run the task!

Returns the value of `task`. Blocks `task` until it is realised.
If `task` is successful, returns its value.
If it is failed, returns a collection of `Throwable` error objects.
Note: Doesn't run the task!
sourceraw docstring

get-or-elseclj

(get-or-else task else)
(get-or-else task timeout else)

Returns the value of task if it was successful, returns else otherwise. Blocks task until it is realised. Note: Doesn't run the task!

Returns the value of `task` if it was successful,
returns `else` otherwise. Blocks `task` until it is realised.
Note: Doesn't run the task!
sourceraw docstring

mapplyclj

(mapply f & tasks)

Takes all the values of tasks and lazily applies a function f on them if they were successful. If one task fails, the total result will be a failure. tasks will be run in parallel. f is allowed to return both simple values and other tasks. The arity of f is equal to the amount of tasks. The following law applies: (arity f) == (count tasks)

Takes all the values of `tasks` and lazily applies a
function `f` on them if they were successful.
If one task fails, the total result will be a failure.
`tasks` will be run in parallel.
`f` is allowed to return both simple values and other tasks.
The arity of `f` is equal to the amount of `tasks`.
The following law applies:
(arity f) == (count tasks)
sourceraw docstring

parallelclj

source

recoverclj

(recover task f)

Recovers a failed task with function f. f has as argument the Throwable error object that occurred during execution. f may either return a simple value or another task.

Note: In the case of parallel tasks, the f will have as an argument the Throwable object of the first execution that failed.

Recovers a failed `task` with function `f`.
`f` has as argument the `Throwable` error object that occurred during execution.
`f` may either return a simple value or another task.

Note:
 In the case of parallel tasks, the `f` will have as an argument the `Throwable` object of
 the first execution that failed.
sourceraw docstring

recover-ascljmacro

(recover-as task value)
source

Resultclj

source

runclj

(run task)

Runs task synchronously. Returns another task containing the result of that execution. Note: Parallel tasks will be run in parallel, but the current thread will be blocked until all tasks realise.

Runs `task` synchronously.
Returns another task containing the result of that execution.
Note: Parallel tasks will be run in parallel,
but the current thread will be blocked until all tasks realise.
sourceraw docstring

run-asyncclj

(run-async task)

Runs task asynchronously. Returns another task containing the result of that execution. Note: Returns immediately. Parallel tasks will be run in parallel.

Runs `task` asynchronously.
Returns another task containing the result of that execution.
Note: Returns immediately. Parallel tasks will be run in parallel.
sourceraw docstring

sequencedclj

(sequenced tasks)

Takes a collection of tasks and lazily transforms it in a task containing a collection of all the values of those tasks. If one task fails, the total result will be a failure. tasks will be run sequentially.

Takes a collection of tasks and lazily transforms it in a task containing
a collection of all the values of those tasks.
If one task fails, the total result will be a failure.
`tasks` will be run sequentially.
sourceraw docstring

sequenced-parclj

(sequenced-par tasks)

Takes a collection of tasks and lazily transforms it in a task containing a collection of all the values of those tasks. If one task fails, the total result will be a failure. tasks will be run in parallel.

Takes a collection of tasks and lazily transforms it in a task containing
a collection of all the values of those tasks.
If one task fails, the total result will be a failure.
`tasks` will be run in parallel.
sourceraw docstring

serialclj

source

successclj

(success value)

Given some value, returns a realised successful task containing the given value

Given some `value`, returns a realised successful task containing the given `value`
sourceraw docstring

taskcljmacro

(task & actions)

Takes and number of expressions or actions and returns a task that will lazily evaluate them.

Takes and number of expressions or actions and
returns a task that will lazily evaluate them.
sourceraw docstring

thenclj

(then task f)

Lazily applies a function f on the value of task only in case it is successful. f is allowed to return both simple values or other tasks. The following law applies: (then (task 1) #(inc %)) == (then (task 1) #(task (inc %))

Lazily applies a function `f` on the value of `task` only
in case it is successful. `f` is allowed to return both simple
values or other tasks.
The following law applies:
 (then (task 1) #(inc %)) == (then (task 1) #(task (inc %))
sourceraw docstring

then-docljmacro

(then-do task & body)

A version of then where the result of task is ignored. Lazily runs the body after the task ignoring the tasks return. Mainly thought for sequential side-effects. The following law applies: (-> (task 1) (then-do (println 12))) == (do-tasks [_ (task 1) _ (println 12)])

A version of `then` where the result of `task` is ignored.
Lazily runs the `body` after the `task` ignoring the `task`s return.
Mainly thought for sequential side-effects.
The following law applies:
 (-> (task 1) (then-do (println 12))) == (do-tasks [_ (task 1) _ (println 12)])
sourceraw docstring

waitclj

(wait task)
(wait task timeout else)

Blocks thread until task has been realised.

Blocks thread until `task` has been realised.
sourceraw docstring

zipclj

(zip & tasks)

Takes the values of tasks and aggregates them to a vector if they were successful. If one task fails, the total result will be a failure. tasks will be run in parallel.

Takes the values of `tasks` and aggregates them to a vector if they were successful.
If one task fails, the total result will be a failure.
`tasks` will be run in parallel.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close