git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-05-31 00:01:32 +00:00
Родитель dd20f90408
Коммит 1c01f22d93
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -77,28 +77,36 @@ class PStoreTest < Test::Unit::TestCase
def test_thread_safe
assert_raise(PStore::Error) do
flag = false
Thread.new do
th = Thread.new do
@pstore.transaction do
@pstore[:foo] = "bar"
flag = true
sleep 1
end
end
begin
sleep 0.1 until flag
@pstore.transaction {}
ensure
th.join
end
end
begin
pstore = PStore.new(second_file, true)
flag = false
Thread.new do
th = Thread.new do
pstore.transaction do
pstore[:foo] = "bar"
flag = true
sleep 1
end
end
begin
sleep 0.1 until flag
assert_equal("bar", pstore.transaction { pstore[:foo] })
ensure
th.join
end
end
ensure
File.unlink(second_file) rescue nil