concept pcall in category clojure
appears as: pcalls

This is an excerpt from Manning's book Clojure: The Essential Reference MEAP V30.
“pmap, pcalls and pvalues” executes the map
operation on a separate thread thus creating a parallelmap
. Replacingmap
with “pmap, pcalls and pvalues” makes sense when the overall cost of handling the functionf
to separate threads is less than the execution off
itself. Long or otherwise processor-consuming operations usually benefit from using “pmap, pcalls and pvalues”.
pmap
,pcalls
andpvalues
build a lazy sequence as the result of processing a set of expressions in parallel (using futures). Bothpcalls
andpvalues
build on top ofpmap
.pmap
has a similar interface to map, but transformations apply to the input in parallel:(pmap + (range 10) (range 10)) ; #1 ;; (0 2 4 6 8 10 12 14 16 18)
pcalls
builds on top ofpmap
accepting any number of functions as input. It then creates a lazy sequence from the results of calling the functions without arguments.pcalls
is a good solution for side effecting parallel transformations: