Created
February 18, 2012 03:24
-
-
Save daveray/1857189 to your computer and use it in GitHub Desktop.
dosync test
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
# https://github.com/daveray/familiar | |
require 'familiar' | |
class DoSyncTest | |
def initialize() | |
@my_ref = Familiar.ref 0 | |
end | |
def test_threaded_refs | |
threads = [] | |
4.times do |i| | |
threads << Thread.new do | |
Familiar.dosync do | |
Familiar.alter @my_ref, Familiar[:inc] | |
end | |
end | |
end | |
threads.each { |t| t.join } | |
puts "my_ref = #{@my_ref.deref}" | |
end | |
end | |
DoSyncTest.new.test_threaded_refs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment