Laurent PETIT a écrit : > I haven't tried with something simpler that the array-like method, I > suspect it won't work in clojure, too. And I didn't want to use > clojure's mutable methods because : > - we already are in an IO operation, the mutation is local to the > operation > - I don't want agents, because I don't want asynchronous behaviour > - I don't want refs, because I don't have to coordinate access on > several places by several threads > - I don't want atoms, because I also don't have to serialize access to > a single place by several threads >
Hello Laurent, Not going with atom sounds like a premature optimization to me. Is the overhead of using atom that important compared to what is executed in the body of sync-exec? In tight loops, the JVM seems to optimize away this overhead: user=> (time (let [a (make-array Object 1)] (dotimes [i 10000000] (aset a 0 2)))) "Elapsed time: 1323.697565 msecs" nil user=> (time (let [a (atom 0)] (dotimes [i 10000000] (swap! a inc)))) "Elapsed time: 991.807898 msecs" nil Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---