1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test/rinda/test_rinda.rb: Start keeper only on used tests

to reduce sleeping threads on unrelated tests

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2018-08-13 12:22:43 +00:00
parent 0ab6266c9d
commit 50e41f4a4f

View file

@ -17,16 +17,36 @@ class MockClock
def keeper_thread
nil
end
def stop_keeper
if @keeper
@keeper.kill
@keeper.join
@keeper = nil
end
end
end
def initialize
@now = 2
@reso = 1
@ts = nil
@inf = 2**31 - 1
end
def start_keeper
@now = 2
@reso = 1
@ts&.stop_keeper
@ts = MyTS.new
@ts.write([2, :now])
@inf = 2**31 - 1
end
def stop_keeper
@ts.stop_keeper
end
def now
@now.to_f
end
@ -100,6 +120,14 @@ class TupleSpace
end
module TupleSpaceTestModule
def setup
MockClock.instance.start_keeper
end
def teardown
MockClock.instance.stop_keeper
end
def sleep(n)
if Thread.current == Thread.main
Time.forward(n)
@ -446,6 +474,7 @@ class TupleSpaceTest < Test::Unit::TestCase
include TupleSpaceTestModule
def setup
super
ThreadGroup.new.add(Thread.current)
@ts = Rinda::TupleSpace.new(1)
end
@ -457,6 +486,7 @@ class TupleSpaceTest < Test::Unit::TestCase
th.join
end
}
super
end
end
@ -464,6 +494,7 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
include TupleSpaceTestModule
def setup
super
ThreadGroup.new.add(Thread.current)
@ts_base = Rinda::TupleSpace.new(1)
@ts = Rinda::TupleSpaceProxy.new(@ts_base)
@ -478,6 +509,7 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
end
}
@server.stop_service
super
end
def test_remote_array_and_hash