Created
December 9, 2010 02:00
-
-
Save anonymous/734222 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/cloby ➔ cat examples/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/cloby ➔ jruby -rubygems -rjavalib/clojure-1.2.0.jar examples/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