On Sat, Oct 11, 2008 at 9:50 PM, Mark McGranaghan <[EMAIL PROTECTED]> wrote: > > I was just wondering what the intended use is for > TransactionalHashMap. Its a Java class defined in the Clojure source, > but not used anywhere else in the core code. How does this class fit > in with Clojure's PersistentHashMap and Java's ConcurrentHashMap?
"rhickey added TransactionalHashMap, an implementation of java.util.ConcurrentHashMap that works in/with transactions" http://clojure-log.n01se.net/date/2008-08-01.html#09:36 It looks to me like it's mutable, but all the data is actually stored in refs, so you can only do your mutations in a transaction: (def x (dosync (doto (clojure.lang.TransactionalHashMap.) (put :a 1) (put :b 2)))) So: thread safe, transactional, mutable ConcurrentHashMap. Maybe it'd be useful for passing into Java libs? Unfortunately you apparently can't print them in SVN 1063: java.lang.ClassCastException: clojure.lang.PersistentHashMap cannot be cast to java.util.Collection at clojure.lang.TransactionalHashMap.entrySet(TransactionalHashMap.java:127) at clojure.lang.RT.seqFrom(RT.java:463) at clojure.lang.RT.seq(RT.java:452) at clojure.seq__28.invoke(boot.clj:92) at clojure.fn__1952$fn__1954.invoke(boot.clj:3524) at clojure.print_ctor__1889.invoke(boot.clj:3433) at clojure.fn__1952.invoke(boot.clj:3517) at clojure.lang.MultiFn.invoke(MultiFn.java:152) at clojure.lang.Var.invoke(Var.java:323) at clojure.lang.RT.print(RT.java:1165) at clojure.lang.Repl.main(Repl.java:88) --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---