1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/projects/fastthread/test/test_condvar.rb
mental a114bc38d1 Always require 'thread' in tests
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@511 19e92222-5c0b-0410-8929-a290d50e31e9
2007-01-26 01:06:49 +00:00

34 lines
628 B
Ruby

require 'test/unit'
require 'thread'
if RUBY_PLATFORM != "java"
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
require 'fastthread'
end
class TestCondVar < Test::Unit::TestCase
def test_signal
s = ""
m = Mutex.new
cv = ConditionVariable.new
ready = false
t = Thread.new do
nil until ( Thread.pass ; m.synchronize { ready } )
m.synchronize { s << "b" }
cv.signal
end
m.synchronize do
s << "a"
ready = true
cv.wait m
assert m.locked?
s << "c"
end
t.join
assert_equal "abc", s
end
end