From: James Gray Date: 2008-03-18T22:54:48+09:00 Subject: Re: Thread#raise, Thread#kill, and timeout.rb are unsafe On Mar 18, 2008, at 12:04 AM, Tanaka Akira wrote: > In article , > Yukihiro Matsumoto writes: > >> What should safe point declaration mechanism look like? > > Basically, asynchronous events should be queued. > > * make a queue for each thread. > * Thread#raise(exc) enqueue exc to the queue. > * Thread.check_interrupt(klass) checks an exception which is > a kind of klass in the queue of the current thread. If it > exists, the exception is raised. > * other queue examining mechanism, such as sigpending, etc, > may be useful. Perl went kind-of along these lines around version 5.8, if I recall correctly. They added "safe signals" which were signals that only interrupted at times when it was safe for them to do so. This did have a few weird side-effects though. For example, running a complex regex would shutoff signal handling for the duration. That meant you could no longer timeout a regex. Perhaps they've fixes these issues now, but I remember the change was not as smooth as they had hoped it would be. James Edward Gray II