Hi Peter,

Thanks for that- that confirms my current (somewhat limited) 
understanding of $SAFE thus far. Thanks for the reference to Celluloid, 
btw- this might help a bit. :)

Garth

On 19/12/11 12:06, Peter Zotov wrote:
> Garthy D ڧѧ 18.12.2011 12:16:
>> Hi all,
>>
>> (snip)
>>
>> For example, many of the criteria in a $SAFE level of 4 seem
>> appropriate to me- although what I'm really after is a way to lock
>> things up, call some user code, and then revert back to a normal $SAFE
>> level. It looks like the only way this could really be done though is
>> to launch the plugin in its own (Ruby) thread and handle any
>> synchronisation issues arising from it myself. Is this right?
>
> I want to note that $SAFE value is set per-thread[1], so you can load your
> plugin into an anonymous namespace (Kernel#load second argument) and then
> spawn a thread from there, using some library (Celluloid[2]?) to
> communicate
> with the code in it.
>
> I should say that I'm not sure that $SAFE is, well, safe for your needs, as
> I'm not familiar with it at all.
>
> 1: http://rxr.whitequark.org/mri/source/safe.c#040
> 2: https://github.com/tarcieri/celluloid
>