From: Dossy Date: 2002-05-09T11:54:40+09:00 Subject: Thread#join doesn't accept a timeout? Hi, In trying to port JUnitPerf (which supplies nice test decorators for TimedTest and such) to Test::Unit for Ruby, I realized that Thread#join takes no args, unlike Java where you can optionally pass a timeout. I hacked around it like so: timeout = 3 # seconds rd, wr = IO.pipe t = Thread.new do # do some stuff wr.write "done" wr.close end selected = select([rd], nil, nil, timeout) if selected.nil? or selected[0].size == 0 t.kill end rd.close t.join This "works" but I'm not confident this is the best way of doing it. I also noticed that there's no Kernel#alarm ... you can Kernel#trap SIGALRM, but there's no way to set an alarm in Ruby (that I can see) without using Kernel#syscall or a native .so. Ideally, Thread#join would look something like this: def join(timeout = nil) ... end timeout = nil means wait forever, timeout = 0 means don't wait, and timeout >0 means wait that many milliseconds. Also, is there any interest in my Test::Unit::TimedTestCase? -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)