As best I can tell, this is yet another "on your honor" STM
implementation. What I mean is that as long as you use the library
correctly in every place where it is needed, everything works fine.
Forgot to use it somewhere in an application where it was needed and
all bets are off. That's one thing I really like about Clojure. You
can't get away with forgetting to update Refs inside a transaction. If
you do, you'll be reminded with an exception.
Is there another STM implementation that enforces its use like this?
--
R. Mark Volkmann
Object Computing, Inc.
I assume Haskell tells you at compile time.
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
Well, I'd say that's a property of the language, not the library. You
could use pretty much any STM library in Java if you can make sure
that the executed bytecode has the appropriate calls in place. Have a
look at Terracotta (http://terracotta.org/). It's not an STM in the
sense of intra-JVM transactions, but inter-JVM transactions (they call
it network attached memory), and it's implemented as a bytecode weaver
(meaning you either transform your compiled class files with an
additional step after compilation to add the library specific
instructions, or you do the same thing at loadtime when loading your
code through a special classloader). Terracotta's approach is also "on
your honor" in the sense that it doesn't force you to declare all
variables in TC terms, but the approach could be extended to throw
(compile time) exceptions on undeclared state variables.
By the way, I would take a good look at Terracotta if I ever wanted to
extend Clojures STM to work across JVMs. You probably would have to
think a bit harder about how you integrate the TC transactions with
the ones from Clojure, since TC transactions are remote calls and
therefore a lot slower, but I reckon it shouldn't be too hard. TC has
enough tools to inspect how your transactions perform.
HTH
Cheers,
Daniel
Oh, and just to complete the picture for intra-JVM transactions on
shared state (clustering), besides Terracotta there's also Hazelcast
(http://www.hazelcast.com/), and to a lesser degree (different focus)
ZooKeeper (http://hadoop.apache.org/zookeeper/) and Shoal
(https://shoal.dev.java.net/). But you'll have to check what the
libraries are aimed at, since the implementations are designed for
certain usecases. And all of these are implemented and used as
traditional libraries as opposed to Terracotta.