Merge pull request #8 from ms-ati/fix-cond-var-signal-when-no-waiters

Fix ConditionVariable#signal to only post if semaphore has waiters
This commit is contained in:
pmahoney committed 2013-12-27 14:49:04 -08:00
commit 1b1fdbe287
2 files changed
+17 -1

No files matched your search

@@ -63,5 +63,19 @@ module ProcessShared
(Time.now.to_f - start).must be_gte(0.1)
}
end
it 'correctly handles #signal when no waiters' do
mutex = Mutex.new
cond = ConditionVariable.new
# fix for bug: #wait not waiting after unmatched call to #signal
cond.signal
mutex.synchronize {
start = Time.now.to_f
cond.wait(mutex, 0.1)
(Time.now.to_f - start).must be_gte(0.1)
}
end
end
end