From: Eric Hodel Date: 2006-09-19T15:48:27+09:00 Subject: Re: timeout and ensure On Sep 18, 2006, at 6:01 PM, Arnaud Bergeron wrote: > On 9/18/06, Eric Hodel wrote: >> Careful, you may want: >> >> ensure >> orig_crit = Thread.critical >> Thread.critical = true >> # do stuff >> Thread.critical = orig_crit >> end >> >> If you may already be inside a critical section. >> >> (or require 'thread' use Thread.exclusive) > > This still leaves the race problem. Where did I say this fixed any race conditions? > If you can raise an exception between an ensure and its first > instruction, This appears to be impossible in the current interpreter. > NOTHING can be safe in the ensure clause. If the first node is begin, then you appear to be safe. See my response to the first message in this thread. > To solve this problem would require some changes to the language > semantics. At the very least external exceptions should not be > accepted when inside an ensure clause. This would require some > interpreter changes and certainly more thougth than what I have given > it. Threads are switched after returning from rb_eval, not before. The first node inside an ensure will always be executed. Your thread may be switched after you begin to return from rb_eval. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com