--00163630ea9d3930b0046e99a9b4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hey,

I'm trying to use rb_eval_string to execute a bunch of code and return from
it straight away. My problem is that the code I want to eval contains a
continuous loop. Even if I wrap the code in a thread the call still blocks
due to the loop. Note that I don't get the same behaviour when using eval()
outside of the C API.

E.g:

rb_eval_string("Thread.new { loop { puts 1; sleep 0.2 }}"); <-- blocks
eval("Thread.new { loop { puts 1; sleep 0.2 }}") <--- doesn't block

My guess is to spawn a ruby thread in C and call rb_eval_string inside that,
I can't find any examples of using the thread functions on google though so
I'm a bit stuck. Could someone give me a few pointers or perhaps some
example code?

Many thanks
Ian

--00163630ea9d3930b0046e99a9b4--