Created
December 9, 2010 02:26
-
-
Save headius/734247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/projects ➔ gem install cloby | |
Successfully installed cloby-0.0.1-java | |
1 gem installed | |
Installing ri documentation for cloby-0.0.1-java... | |
Installing RDoc documentation for cloby-0.0.1-java... | |
~/projects ➔ cat simple.rb | |
require 'cloby' | |
class MyClojureObj < Clojure::Object | |
def initialize | |
dosync { @foo = 'foo' } | |
end | |
attr_accessor :foo | |
end | |
obj = MyClojureObj.new | |
puts "obj.foo = " + obj.foo | |
begin | |
puts "Setting obj.foo to 'bar'" | |
obj.foo = 'bar' | |
rescue ConcurrencyError | |
puts "Oops, need a transaction" | |
end | |
puts "Trying again with a transaction" | |
dosync { obj.foo = 'bar' } | |
puts "Success" | |
puts "obj.foo == " + obj.foo | |
~/projects ➔ jruby -rubygems -rclojure/clojure-1.0.0.jar simple.rb | |
obj.foo = foo | |
Setting obj.foo to 'bar' | |
Oops, need a transaction | |
Trying again with a transaction | |
Success | |
obj.foo == bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment