First you start a Terracotta server. Then you run a Kawa shell through the following command:
java -Xbootclasspath/p:[terracotta boot jar] -Dtc.config=tc-config.xml -Dtc.install-root=[terracotta install dir] -jar kawa.jarJust as with JScheme, boot jar is is a stub jar file that starts a Terracotta client before the main application and tc-config is a Terracotta configuration file (see the post about JScheme for details).
Next, you load the Terracotta library:
(load "kwtc.scm")and define an object (for example an ArrayList) to share across the cluster:
(define ob (create-root "list" (make <java.util.ArrayList>)))Now you can put values on the list:
(sync-write (lambda () (ob:add 1)) ob)and read them back synchronously:
(sync-read (lambda () (ob:get 0)) ob))or simply with:
(ob:get 0)The library for Kawa can be downloaded from here.
Happy coding!
No comments:
Post a Comment