Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mention the JRuby nested-transactions bug in the readme.

  • Loading branch information...
commit 00638e796914dfba00815e24ed42add41c8aaec6 1 parent d669016
@technomancy authored
Showing with 28 additions and 3 deletions.
  1. +11 −3 README.rdoc
  2. +17 −0 test/test_ref.rb
View
14 README.rdoc
@@ -7,19 +7,27 @@ http://github.com/technomancy/clojure-gem
Use Clojure's immutable data structures and Software Transactional
Memory from Ruby. Don't be afraid of concurrency.
-Requires JRuby. Tested with 1.3.1+.
+Requires JRuby. Tested with 1.4.0+.
Supports all four persistent collection types (lists, vectors, maps,
and sets). Many enumerable methods still return Ruby arrays instead of
the original type; this will be fixed. Lazy sequences are not yet
supported.
+== Issues
+
+JRuby's way of nesting exceptions means that the exceptions used for
+transaction retries in dosync are not caught correctly. This may
+necessitate shipping a patched version of Clojure to fix. See the
+test_threaded_refs test in test_ref.rb for details; changing "commute"
+to "alter" makes it fail.
+
== Examples
TODO: write examples
== License
-Copyright (c) Phil Hagelberg
+Copyright (c) Phil Hagelberg 2009
-Released under the Eclipse Public License. See file COPYING.
+Released under the Eclipse Public License. See file COPYING.
View
17 test/test_ref.rb
@@ -34,4 +34,21 @@ def test_set_outside_transaction
@ref.set 2
end
end
+
+ def test_threaded_refs
+ threads = []
+ inc = Proc.new {|v| v + 1 }
+
+ 10.times do |i|
+ threads << Thread.new do
+ Ref.dosync do
+ @ref.commute {|v| v + 1 }
+ @ref.commute(inc)
+ end
+ end
+ end
+
+ threads.each { |t| t.join }
+ assert_equal 21, @ref.deref
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.