Last active
February 29, 2016 08:58
-
-
Save fukuiretu/e3a18e26b246ae512988 to your computer and use it in GitHub Desktop.
parallelのスレッドセーフ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
require 'parallel' | |
class Dummy | |
def initialize | |
@cnt = 0 | |
end | |
def increment | |
@cnt += 1 | |
end | |
def test | |
arr = (1..10000000).to_a | |
Parallel.each(arr, in_threads: 10) do | |
increment | |
end | |
p @cnt # 10000000 | |
end | |
end | |
Dummy.new.test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/grosser/parallel/blob/master/lib/parallel.rb#L75-L92