Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7b23ca8e4e
Fetching contributors…

Cannot retrieve contributors at this time

executable file 37 lines (26 sloc) 1.43 kb
A groovy library/dsl for using clojure's STM in groovy/grails applications.
this is just a thin layer of syntactic sugar on top of the java objects that implement the clojure language.
Not all concepts implemented here map exactly the their clojure namesakes.
Note, it is highly recommended that you understand how to use the objects in clojure first
This library is intended to be a vessel to sneak clojure.jar into your enterprise applications.
See Neal Ford's master plan for enterprise mindshare at
http://blip.tv/clojure/neal-ford-neal-s-master-plan-for-clojure-enterprise-mindshare-domination-5953926
Once you get used to the joy of coding your concurrency using this model, silently switch your
groovy scripts over to clj and enjoy the rest
See Dr. Venkat Subramaniam's materials from his "Taming Shared Mutability with STM" at http://agiledeveloper.com/downloads.html for examples and concepts in using clojure STM from Java
Example usage:
import clojure.lang.Ref
import static groovystm.STM.doSync
import static groovystm.STM.alter
class MyStateClass {
/** Make sure your Ref's wrap immutable objects - try out clojure.lang.PersistentHashMap for example */
Ref balanceRef = new Ref(0)
int deposit(int amt) {
doSync {
alter(balanceRef) { balance -> balance + amt }
}
}
int currentBalance() {
deref(balanceRef)
}
}
Jump to Line
Something went wrong with that request. Please try again.