Liking cljdoc? Tell your friends :D

com.climate.claypoole.lazy

Lazy threadpool tools for Clojure.

This namespace provides lazy versions of the parallel functions from com.climate.claypoole. They will only run the outputs you realize, plus a few more (a buffer), just like core pmap. The buffer is used to help keep the threadpool busy.

Each parallel function also comes with a -buffer variant that allows you to specify the buffer size. The non -buffer forms use the threadpool size as their buffer size.

To use the threadpool most efficiently with these lazy functions, prefer the unordered versions (e.g. upmap), since the ordered ones may starve the threadpool of work. For instance, this pmap will take 6 milliseconds to run: (lazy/pmap 2 #(Thread/sleep %) [4 3 2 1]) That's because it will not realize the 2 task until the 4 task is complete, so one thread in the pool will sit idle for 1 millisecond.

Lazy threadpool tools for Clojure.

This namespace provides lazy versions of the parallel functions from
com.climate.claypoole. They will only run the outputs you realize, plus a few
more (a buffer), just like core pmap. The buffer is used to help keep the
threadpool busy.

Each parallel function also comes with a -buffer variant that allows you to
specify the buffer size. The non -buffer forms use the threadpool size as
their buffer size.

To use the threadpool most efficiently with these lazy functions, prefer the
unordered versions (e.g. upmap), since the ordered ones may starve the
threadpool of work. For instance, this pmap will take 6 milliseconds to run:
  (lazy/pmap 2 #(Thread/sleep %) [4 3 2 1])
That's because it will not realize the 2 task until the 4 task is complete,
so one thread in the pool will sit idle for 1 millisecond.
raw docstring

pcallsclj

(pcalls pool & fs)

Like clojure.core.pcalls, except it's lazy and it takes a threadpool. For more detail on its parallelism and on its threadpool argument, see pmap.

Like clojure.core.pcalls, except it's lazy and it takes a threadpool. For
more detail on its parallelism and on its threadpool argument, see pmap.
sourceraw docstring

pcalls-bufferclj

(pcalls-buffer pool buffer & fs)

Like clojure.core.pcalls, except it's lazy and it takes a threadpool and a buffer size. For more detail on these arguments, see pmap-buffer.

Like clojure.core.pcalls, except it's lazy and it takes a threadpool and a
buffer size. For more detail on these arguments, see pmap-buffer.
sourceraw docstring

pdoseqcljmacro

(pdoseq pool bindings & body)

Like doseq, but in parallel. Unlike the streaming sequence functions (e.g. pmap), pdoseq blocks until all the work is done.

Similar to pfor, only the body is done in parallel. For more details, see pfor.

Like doseq, but in parallel. Unlike the streaming sequence functions (e.g.
pmap), pdoseq blocks until all the work is done.

Similar to pfor, only the body is done in parallel. For more details, see
pfor.
sourceraw docstring

pforcljmacro

(pfor pool bindings & body)

A parallel version of for. It is like for, except it takes a threadpool and is parallel. For more detail on its parallelism and on its threadpool argument, see pmap.

Note that while the body is executed in parallel, the bindings are executed in serial, so while this will call complex-computation in parallel: (pfor pool [i (range 1000)] (complex-computation i)) this will not have useful parallelism: (pfor pool [i (range 1000) :let [result (complex-computation i)]] result)

You can use the special binding :priority (which must be the last binding) to set the priorities of the tasks. (upfor (priority-threadpool 10) [i (range 1000) :priority (inc i)] (complex-computation i))

A parallel version of for. It is like for, except it takes a threadpool and
is parallel. For more detail on its parallelism and on its threadpool
argument, see pmap.

Note that while the body is executed in parallel, the bindings are executed
in serial, so while this will call complex-computation in parallel:
    (pfor pool [i (range 1000)] (complex-computation i))
this will not have useful parallelism:
    (pfor pool [i (range 1000) :let [result (complex-computation i)]] result)

You can use the special binding :priority (which must be the last binding) to
set the priorities of the tasks.
    (upfor (priority-threadpool 10) [i (range 1000)
                                     :priority (inc i)]
      (complex-computation i))
sourceraw docstring

pfor-buffercljmacro

(pfor-buffer pool buffer bindings & body)

Like pfor, but it takes a buffer size; see pmap-buffer for information about this argument.

Like pfor, but it takes a buffer size; see pmap-buffer for information about
this argument.
sourceraw docstring

pmapclj

(pmap pool f & colls)

A lazy pmap where the work happens in a threadpool, just like core pmap, but using Claypoole futures in the given threadpool.

Unlike core pmap, it doesn't assume the buffer size is nprocessors + 2; instead, it tries to fill the pool.

If you (doall (take 2 (pmap 10 inc (range 1000)))) then 12 inputs and outputs will be realized--the 2 you asked for, plus the 10 that are run in the buffer to keep the threadpool busy.

A lazy pmap where the work happens in a threadpool, just like core pmap, but
using Claypoole futures in the given threadpool.

Unlike core pmap, it doesn't assume the buffer size is nprocessors + 2;
instead, it tries to fill the pool.

If you
  (doall (take 2 (pmap 10 inc (range 1000))))
then 12 inputs and outputs will be realized--the 2 you asked for, plus the 10
that are run in the buffer to keep the threadpool busy.
sourceraw docstring

pmap-bufferclj

(pmap-buffer pool buffer-size f & colls)

A lazy pmap where the work happens in a threadpool, just like core pmap, but using Claypoole futures.

Unlike core pmap, it doesn't assume the buffer size is nprocessors + 2; instead, you must specify how many tasks ahead will be run in the background.

If you (doall (take 2 (pmap-buffer pool 10 inc (range 1000)))) then 12 inputs and outputs will be realized--the 2 you asked for, plus the 10 that are run in the buffer to keep the threadpool busy.

A lazy pmap where the work happens in a threadpool, just like core pmap, but
using Claypoole futures.

Unlike core pmap, it doesn't assume the buffer size is nprocessors + 2;
instead, you must specify how many tasks ahead will be run in the
background.

If you
  (doall (take 2 (pmap-buffer pool 10 inc (range 1000))))
then 12 inputs and outputs will be realized--the 2 you asked for, plus the 10
that are run in the buffer to keep the threadpool busy.
sourceraw docstring

prun!clj

(prun! pool proc coll)

Like run!, but in parallel. Unlike the streaming sequence functions (e.g. pmap), prun! blocks until all the work is done.

Like run!, but in parallel. Unlike the streaming sequence functions (e.g.
pmap), prun! blocks until all the work is done.
sourceraw docstring

pvaluescljmacro

(pvalues pool & exprs)

Like clojure.core.pvalues, except it's lazy and it takes a threadpool. For more detail on its parallelism and on its threadpool argument, see pmap.

Like clojure.core.pvalues, except it's lazy and it takes a threadpool. For
more detail on its parallelism and on its threadpool argument, see pmap.
sourceraw docstring

pvalues-buffercljmacro

(pvalues-buffer pool buffer & exprs)

Like clojure.core.pvalues, except it's lazy and it takes a threadpool and a buffer size. For more detail on its parallelism and on its arguments, see pmap-buffer.

Like clojure.core.pvalues, except it's lazy and it takes a threadpool and a
buffer size. For more detail on its parallelism and on its arguments, see
pmap-buffer.
sourceraw docstring

upcallsclj

(upcalls pool & fs)

Like clojure.core.pcalls, except it's lazy, it takes a threadpool, and it returns results ordered by completion time. For more detail on its parallelism and on its threadpool argument, see upmap.

Like clojure.core.pcalls, except it's lazy, it takes a threadpool, and it
returns results ordered by completion time. For more detail on its
parallelism and on its threadpool argument, see upmap.
sourceraw docstring

upcalls-bufferclj

(upcalls-buffer pool buffer & fs)

Like clojure.core.pcalls, except it's lazy, it takes a threadpool and a buffer size, and it returns results ordered by completion time. For more detail on its parallelism and on its arguments, see upmap-buffer.

Like clojure.core.pcalls, except it's lazy, it takes a threadpool and a
buffer size, and it returns results ordered by completion time. For more
detail on its parallelism and on its arguments, see upmap-buffer.
sourceraw docstring

upforcljmacro

(upfor pool bindings & body)

Like pfor, except the return value is a sequence of results ordered by completion time, not by input order.

Like pfor, except the return value is a sequence of results ordered by
*completion time*, not by input order.
sourceraw docstring

upfor-buffercljmacro

(upfor-buffer pool buffer bindings & body)

Like upfor, but it takes a buffer size; see pmap-buffer for information about this argument.

Like upfor, but it takes a buffer size; see pmap-buffer for information
about this argument.
sourceraw docstring

upmapclj

(upmap pool f & colls)

Like pmap, but with results returned in the order they completed.

Note that unlike core pmap, it doesn't assume the buffer size is nprocessors

  • 2; instead, it tries to fill the pool.
Like pmap, but with results returned in the order they completed.

Note that unlike core pmap, it doesn't assume the buffer size is nprocessors
+ 2; instead, it tries to fill the pool.
sourceraw docstring

upmap-bufferclj

(upmap-buffer pool buffer-size f & colls)

Like pmap-buffer, but with results returned in the order they completed.

Note that unlike core pmap, it doesn't assume the buffer size is nprocessors

  • 2; instead, you must specify how many tasks ahead will be run in the background.
Like pmap-buffer, but with results returned in the order they completed.

Note that unlike core pmap, it doesn't assume the buffer size is nprocessors
+ 2; instead, you must specify how many tasks ahead will be run in the
background.
sourceraw docstring

upvaluescljmacro

(upvalues pool & exprs)

Like clojure.core.pvalues, except it's lazy, it takes a threadpool, and it returns results ordered by completion time. For more detail on its parallelism and on its threadpool argument, see upmap.

Like clojure.core.pvalues, except it's lazy, it takes a threadpool, and it
returns results ordered by completion time. For more detail on its
parallelism and on its threadpool argument, see upmap.
sourceraw docstring

upvalues-buffercljmacro

(upvalues-buffer pool buffer & exprs)

Like clojure.core.pvalues, except it's lazy, it takes a threadpool and a buffer size, and it returns results ordered by completion time. For more detail on its parallelism and on its arguments, see upmap-buffer.

Like clojure.core.pvalues, except it's lazy, it takes a threadpool and a
buffer size, and it returns results ordered by completion time. For more
detail on its parallelism and on its arguments, see upmap-buffer.
sourceraw docstring

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

× close