Implementation helper functions for Claypoole.
Implementation helper functions for Claypoole.
(->threadpool arg)
Convert the argument into a threadpool, leaving the special keyword :serial alone.
Returns [created? threadpool], where created? indicates whether a new threadpool was instantiated.
Convert the argument into a threadpool, leaving the special keyword :serial alone. Returns [created? threadpool], where created? indicates whether a new threadpool was instantiated.
(apply-map f & args)
Apply a function that takes keyword arguments to a map of arguments.
Apply a function that takes keyword arguments to a map of arguments.
(binding-conveyor-fn f)
Like clojure.core/binding-conveyor-fn for resetting bindings to run a function in another thread.
Like clojure.core/binding-conveyor-fn for resetting bindings to run a function in another thread.
(default-threadpool-name)
The default name for threads in a threadpool. Gives each threadpool a unique ID via threadpool-id.
The default name for threads in a threadpool. Gives each threadpool a unique ID via threadpool-id.
(deref-fixing-exceptions fut)
If a future experiences an exception and you dereference the future, you will see not the original exception but a java.util.concurrent.ExecutionException. That's sometimes not the result you want. This catches those exceptions and re-throws the future's exception, which can be much less surprising to downstream code.
If a future experiences an exception and you dereference the future, you will see not the original exception but a java.util.concurrent.ExecutionException. That's sometimes not the result you want. This catches those exceptions and re-throws the future's exception, which can be much less surprising to downstream code.
(deref-future fut)
(deref-future fut timeout-ms timeout-val)
Like clojure.core/deref-future.
Like clojure.core/deref-future.
(dummy-future-call f)
A dummy future-call that runs in serial and returns a future containing the result.
A dummy future-call that runs in serial and returns a future containing the result.
(get-pool-size pool)
If the pool has a max size, get that; else, return nil.
If the pool has a max size, get that; else, return nil.
(lazy-co-read s1 s2)
Zip s1 and s2, stopping when s1 stops. This helps avoid potential blocking when trying to read queue sequences.
In particular, this will block: (map vector (range 10) (concat (range 10) (lazy-seq (deref (promise))))) even though we only can read 10 things. Lazy-co-read fixes that case by checking the first sequence first, so this will not block: (lazy-co-read (range 10) (concat (range 10) (lazy-seq (deref (promise)))))
Zip s1 and s2, stopping when s1 stops. This helps avoid potential blocking when trying to read queue sequences. In particular, this will block: (map vector (range 10) (concat (range 10) (lazy-seq (deref (promise))))) even though we only can read 10 things. Lazy-co-read fixes that case by checking the first sequence first, so this will not block: (lazy-co-read (range 10) (concat (range 10) (lazy-seq (deref (promise)))))
(pfor-internal pool bindings body pmap-fn-sym)
Do the messy parsing of the :priority from the for bindings.
Do the messy parsing of the :priority from the for bindings.
(queue-seq)
Create a queue and a lazy sequence that reads from that queue.
Create a queue and a lazy sequence that reads from that queue.
(queue-seq-add! q x)
Add an item to a queue (and its lazy sequence).
Add an item to a queue (and its lazy sequence).
(queue-seq-end! q)
End a lazy sequence reading from a queue.
End a lazy sequence reading from a queue.
(seq-open f s)
Converts a seq s into a lazy seq that calls a function f when the seq is fully realized or when an exception is thrown. Sort of like with-open, but not a macro, not necessarily calling .close, and for a lazy seq.
Converts a seq s into a lazy seq that calls a function f when the seq is fully realized or when an exception is thrown. Sort of like with-open, but not a macro, not necessarily calling .close, and for a lazy seq.
(thread-factory
&
{:keys [daemon thread-priority] pool-name :name :or {daemon true}})
Create a ThreadFactory with keyword options including thread daemon status :daemon, the thread name format :name (a string for format with one integer), and a thread priority :thread-priority.
Create a ThreadFactory with keyword options including thread daemon status :daemon, the thread name format :name (a string for format with one integer), and a thread priority :thread-priority.
(threadpool n & args)
Make a threadpool. It should be shutdown when no longer needed.
See docs in com.climate.claypoole/threadpool.
Make a threadpool. It should be shutdown when no longer needed. See docs in com.climate.claypoole/threadpool.
The previously-used threadpool ID.
The previously-used threadpool ID.
(unchunk s)
Takes a seqable and returns a lazy sequence that is maximally lazy.
Takes a seqable and returns a lazy sequence that is maximally lazy. Based on http://stackoverflow.com/questions/3407876/how-do-i-avoid-clojures-chunking-behavior-for-lazy-seqs-that-i-want-to-short-ci
(validate-future-pool pool)
Verify that a threadpool is a valid pool for a future.
Verify that a threadpool is a valid pool for a future.
(with-priority-fn pool priority-fn)
Make a priority-threadpool wrapper that uses a given priority function.
The priority function is applied to a pmap'd function's arguments. e.g.
(upmap (with-priority-fn p (fn [x _] x)) + [6 5 4] [1 2 3])
will use pool p to run tasks [(+ 6 1) (+ 5 2) (+ 4 3)] with priorities [6 5 4].
Make a priority-threadpool wrapper that uses a given priority function. The priority function is applied to a pmap'd function's arguments. e.g. (upmap (with-priority-fn p (fn [x _] x)) + [6 5 4] [1 2 3]) will use pool p to run tasks [(+ 6 1) (+ 5 2) (+ 4 3)] with priorities [6 5 4].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close