Fix Mutex to allow lock from different Ruby (green) thread in process

This commit is contained in:
Marc Siegel committed 2013-12-27 10:46:50 -05:00
1 parent 3e4fa34694
commit aeadb74ef6
3 files changed
+62 -22

No files matched your search

+28 -1
View File
@@ -24,10 +24,37 @@ module ProcessShared
::Process.wait(pid)
end
it 'raises exception when locked twice by same process' do
it 'raises exception when unlocked by other thread in same process' do
t = Thread.new do
@lock.lock
sleep 0.2
@lock.unlock
end
sleep 0.1
proc { @lock.unlock }.must_raise(ProcessError)
t.join
end
it 'raises exception when locked twice by same process and thread' do
@lock.lock
proc { @lock.lock }.must_raise(ProcessError)
@lock.unlock
end
it 'does not raise when locked by different threads on same process' do
t = Thread.new do
@lock.lock
sleep 0.2
@lock.unlock
end
sleep 0.1
@lock.synchronize { }
t.join
end
end
end