Skip to content
Browse files

Expose RCCounter.new

  • Loading branch information...
1 parent 695a935 commit edf67e7978ff280c9ac17adc511d9c7814c1bd8d @jc00ke jc00ke committed
Showing with 29 additions and 0 deletions.
  1. +19 −0 lib/ruby/1.8/maglev/rccounter.rb
  2. +10 −0 spec/maglev/reducedconflict/counter/new_spec.rb
View
19 lib/ruby/1.8/maglev/rccounter.rb
@@ -0,0 +1,19 @@
+# Reduced Conflict Counter
+# RCCounter is identically Smalltalk RcCounter
+
+RCCounter = __resolve_smalltalk_global(:RcCounter)
+
+# RCCounter is a simple counter that allows multiple users to update it
+# without running into conflicts. It replaces the need for a mutex in
+# normal Ruby programming when implementing a counter that would be accessed
+# by multiple threads.
+#
+# Unlike another counter, RCCounter provides for concurrent handling of an individual
+# instance by multiple sessions. Any or all of those sessions can modify
+# the single instance. When that happens, RCCounter reduces (but does not
+# eliminate) the transaction conflicts that can arise among those sessions
+# when they attempt to commit the instance to GemStone.
+
+class RCCounter
+ class_primitive 'new', 'new'
+end
View
10 spec/maglev/reducedconflict/counter/new_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'maglev/rccounter'
+
+describe "RCCounter.new" do
+
+ it "returns an instance of RCCounter" do
+ RCCounter.new.should be_an_instance_of(RCCounter)
+ end
+
+end

0 comments on commit edf67e7

Please sign in to comment.
Something went wrong with that request. Please try again.