On Sep 17, 2006, at 1:08 PM, khaines / enigo.com wrote:

> On Mon, 18 Sep 2006, Joel VanderWerf wrote:
>
>> I wish I had an easy answer to this problem, but I don't. Are  
>> timeout and ensure inherently incompatible?
>
> I don't have an answer, but what if you make your ensure section  
> into a critical section?
>
> ensure
>   Thread.critical = true
>   # do stuff
>   Thread.critical = false
> end

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)

-- 
Eric Hodel - drbrain / segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com