Ok I can see there is a 'var-set' fn that seems to behave exactly as i
need...this is good stuff!
I can now do:
(var-set clojure.core.reducers/pool (ForkJoinPool. 6))
Jim
On 21/09/12 17:14, Jim foo.bar wrote:
On 21/09/12 16:54, Herwig Hochleitner wrote:
So if you're asking how to control the number of threads used for
folding: That's a constructor argument of ForkJoinPool, which
defaults to the number of available processors.
It's not currently exposed in the reducers API, but you could hack it
with alter-var-root, if you need to:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj#L41
oooo this is exactly what I needed!!! thanks a million Herwig...
Now I've got a way to limit the number of threads in the GA and the
reducers bit as well...
this is brilliant! One tiny issue though...
alter-var-root takes a fn to transform the var plus any potential
args. In this case 'ForkJoinPool' does not have a 'setParallelism(int
x)' method...You can only pass it the ctor when you create the object...
In other words, I cannot simply do:
(alter-var-root pool #(.setParallelism % 6))
and obviously I cannot do :
(alter-var-root pool (ForkJoinPool. 6))
I need to call the ctor and somehow rebind the 'pool' var to that
object. How do I do that? any ideas?
Would 'compare-and-set!' work in this case? are all vars wrapped in
atoms?
Jim
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en