Sha256: 305e3c1569f7fc58d2aa03d6e312739c828b6ac4682fe6455b20bd690253d204
Contents?: true
Size: 827 Bytes
Versions: 4
Compression:
Stored size: 827 Bytes
Contents
#!/usr/bin/env ruby # Test thread safety require "test/unit" require "dbus" def d(msg) puts "#{$$} #{msg}" if $DEBUG end class ThreadSafetyTest < Test::Unit::TestCase def test_thread_competition print "Thread competition: " jobs = [] 5.times do jobs << Thread.new do Thread.current.abort_on_exception = true # use separate connections to avoid races bus = DBus::ASessionBus.new svc = bus.service("org.ruby.service") obj = svc.object("/org/ruby/MyInstance") obj.introspect obj.default_iface = "org.ruby.SampleInterface" 10.times do |i| print "#{i} " $stdout.flush assert_equal 42, obj.the_answer[0] sleep 0.1 * rand end end end jobs.each do |thread| thread.join end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ruby-dbus-0.8.0 | test/thread_safety_test.rb |
ruby-dbus-0.7.2 | test/thread_safety_test.rb |
ruby-dbus-0.7.1 | test/thread_safety_test.rb |
ruby-dbus-0.7.0 | test/thread_safety_test.rb |