[MacRuby] #768: Timeout is broken. It seems MacRuby does not dispatch the Thread.
#768: Timeout is broken. It seems MacRuby does not dispatch the Thread. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Timeout is broken. Even if Timeout which I appointed passed, MacRuby's execution is not finished. {{{ require 'timeout' Timeout::timeout(1) do i = 0 loop do i += 1 end end }}} I think it seems MacRuby does not dispatch the Thread. -- Ticket URL: <http://www.macruby.org/trac/ticket/768> MacRuby <http://macruby.org/>
#768: Timeout is broken. It seems MacRuby does not dispatch the Thread. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: Component: MacRuby | Resolution: duplicate Keywords: | ----------------------------------+----------------------------------------- Changes (by martinlagardette@…): * status: new => closed * resolution: => duplicate Comment: This is a duplicate of a know bug: #176 The problem is not that the thread is not dispatched. It is actually dispatched. But the dispatched thread is not the one that does the operation, it's a thread that sleep for whatever was passed to timeout, and then sends "cancel" to the main thread. However, with the way MacRuby implements threads (with pthread), it's not possible to cancel the main thread without breaking everything :D. We're working on it, and waiting to find a solution. -- Ticket URL: <http://www.macruby.org/trac/ticket/768#comment:1> MacRuby <http://macruby.org/>
On Jun 30, 2010, at 8:07 PM, MacRuby wrote:
#768: Timeout is broken. It seems MacRuby does not dispatch the Thread. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: Component: MacRuby | Resolution: duplicate Keywords: | ----------------------------------+----------------------------------------- Changes (by martinlagardette@…):
* status: new => closed * resolution: => duplicate
Comment:
This is a duplicate of a know bug: #176
The problem is not that the thread is not dispatched. It is actually dispatched. But the dispatched thread is not the one that does the operation, it's a thread that sleep for whatever was passed to timeout, and then sends "cancel" to the main thread. However, with the way MacRuby implements threads (with pthread), it's not possible to cancel the main thread without breaking everything :D.
We're working on it, and waiting to find a solution.
I believe the rubinius guys solved this using the following trick. I may also be completely wrong about it. :) When you create a timeout thread, also create a named socket (or pipe) and add its file descriptor to the set of descriptors that the main loop selects/polls on. Have your timeout thread wake and signal that file descriptor. The main loop will detect the signal on that descriptor and do the appropriate thing. That's also a technique for having signal handlers cleanly terminate the process. They can signal another FD which causes the main loop to clean up after itself and shutdown nicely. cr
Hi. Do you mean that it is a problem to use a MainThread? I post a patch that do not use a MainThread. Please check it. Thank you! On 2010/07/01, at 10:07, MacRuby wrote:
#768: Timeout is broken. It seems MacRuby does not dispatch the Thread. ---------------------------------- +----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: Component: MacRuby | Resolution: duplicate Keywords: | ---------------------------------- +----------------------------------------- Changes (by martinlagardette@…):
* status: new => closed * resolution: => duplicate
Comment:
This is a duplicate of a know bug: #176
The problem is not that the thread is not dispatched. It is actually dispatched. But the dispatched thread is not the one that does the operation, it's a thread that sleep for whatever was passed to timeout, and then sends "cancel" to the main thread. However, with the way MacRuby implements threads (with pthread), it's not possible to cancel the main thread without breaking everything :D.
We're working on it, and waiting to find a solution.
-- Ticket URL: <http://www.macruby.org/trac/ticket/768#comment:1> MacRuby <http://macruby.org/>
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Chuck Remes
-
MacRuby
-
Watson