X
Xavier Noëlle
Hello dear Fellow Rubyists !
I'm currently struggling with Ruby threads, especially the #stop and
#stop? methods. My program has two threads:
- a worker performing tasks and ultimately calling Thread.stop (it is
supposed to do so before to be allowed to continue)
- a monitor asking for the status of the worker thread and waiting
until it has reached the call to Thread.stop
I thought that Thread#stop? would be the way to go for the monitor
thread, but it doesn't seem to do what I want. It doesn't work with
1.9, but seems to work with 1.8, which is quite confusing.
The piece of code trying to wake the worker up as follow:
while !thr.stop?()
Thread.pass()
end
thr.wakeup()
Unfortunately, thr.stop?() never returns false, so I'm basically
trying to wake a thread that is not sleeping !
TIA !
I'm currently struggling with Ruby threads, especially the #stop and
#stop? methods. My program has two threads:
- a worker performing tasks and ultimately calling Thread.stop (it is
supposed to do so before to be allowed to continue)
- a monitor asking for the status of the worker thread and waiting
until it has reached the call to Thread.stop
I thought that Thread#stop? would be the way to go for the monitor
thread, but it doesn't seem to do what I want. It doesn't work with
1.9, but seems to work with 1.8, which is quite confusing.
The piece of code trying to wake the worker up as follow:
while !thr.stop?()
Thread.pass()
end
thr.wakeup()
Unfortunately, thr.stop?() never returns false, so I'm basically
trying to wake a thread that is not sleeping !
TIA !