Created
October 28, 2013 09:34
-
-
Save etehtsea/7193889 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
require 'active_support/notifications' | |
ActiveSupport::Notifications.subscribe 'test_class.create' do |*args| | |
event = ActiveSupport::Notifications::Event.new(*args) | |
p event.payload | |
end | |
class TestClass | |
def initialize | |
@rand_int = rand(10) | |
end | |
def instr | |
ActiveSupport::Notifications.instrument('test_class.create', rand_int: @rand_int) | |
end | |
end | |
threads = [] | |
400_000.times do | |
threads << Thread.new { TestClass.new.instr } | |
end | |
threads.map(&:join) | |
#ConcurrencyError: Detected invalid array contents due to unsynchronized modifications with concurrent users | |
# pop at org/jruby/RubyArray.java:1190 | |
# finish at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/fanout.rb:124 | |
# finish at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/fanout.rb:40 | |
# each at org/jruby/RubyArray.java:1617 | |
# finish at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/fanout.rb:40 | |
# finish at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/instrumenter.rb:36 | |
# instrument at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/instrumenter.rb:25 | |
# instrument at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications/instrumenter.rb:19 | |
# instrument at /Users/kes/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-4.0.1.rc3/lib/active_support/notifications.rb:159 | |
# instr at notifications_thread_safety.rb:15 | |
# (root) at notifications_thread_safety.rb:21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment