Jacob
9/30/2008 9:56:00 AM
Hi all
I am writing a ruby server. Something like:
class MyServer
def initialize
@stop_signal = MySignal.new
end
def start
@stop_signal.reset
@thread = Thread.start { run }
end
def stop
@stop_signal.set
@thread.wait
end
def run
while true
do_process if there_is_some_thing_to_process
@stop_signal.wait 5
end
end
end
Is there any class in ruby that has similar functions to MySignal?
It's easy solution in java or .net.
I have googled, and I found a method call 'timeout', but after read
the source code, I found it uses a new thread to handle timeout. I
think It's not good solution, because on my real system (ported
from .net source code), there are some thread running parallel, and
there are using alot of signal.
Thanks
Jacob