All the parallel work will be done in Clojure, so I think I will go with the refs and atom path. When the processing in Clojure is done the data is passed as XML to another system so Java doesn't need to change it anymore, so the immutability when it's done is not a problem.
Thank you very much for your answer, it really helped :) On Oct 29, 2:43 pm, Shantanu Kumar <kumar.shant...@gmail.com> wrote: > On Oct 29, 4:50 pm, vanallan <vanal...@gmail.com> wrote: > > > Ok thanks for the answer :) > > > I have now began to implement theJavaparts. The data that is going > > to be processed inClojureis mapped toclojurestructs, but I now > > have another question. How should I update the values in the structs? > > Since functions are going to run in parallel and a function may need > > the updated value from another function I though that I should put the > > struct members that is going to be updated in refs or maybe atoms. Is > > this a good way or how should I manage the updated values in structs? > > This, I think depends on your use case. If the parallel functions are > inClojure, then atoms and refs may help. If some functions are inJavaand some > inClojure, and both sets of functions work in parallel > to update commonly stored data then you should stick to > concurrentJavacollections (java.util.concurrent.*). But again, this depends on > the use case. > > I think as long as theJavaconsumer class is ready to acceptjava.util.Map you > can simply return a modified struct and it will be > understood. But there is a pitfall to watch for -- the struct you > return fromClojurewill be immutable, so none of put(), remove() etc > will work inJavathen. When you are integratingJavawithClojureyou > should remember this aspect, and probably you will benefit > tremendously if you code theJavapart in a functional style, for > example: > > 1. Go Immutable -- use the "final" keyword a lot (ensures at least > immutable references) > > 2. Go Functional -- pass objects and anonymous functions (Strategy and > Mediator patterns may help) > > 3. Don't presume data structures to be mutable > > HTH > > Regards, > Shantanu --~--~---------~--~----~------------~-------~--~----~ 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 Note that posts from new members are moderated - please be patient with your first post. 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 -~----------~----~----~----~------~----~------~--~---