<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 8, 2014 at 1:19 AM, Estevo <span dir="ltr"><<a href="mailto:euccastro@gmail.com" target="_blank">euccastro@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>One thing I'd try would be to launch a gambit thread running ##repl-debug-main and set up a timer or idle handler in the main gambit thread that just 'thread-sleep!'s for a small amount of time.  Hopefully experimentation yields a delay that is small enough to be unnoticeable in your application, but large enough to give the REPL enough time to do its work.  If you use a timer for this (or, I imagine, if you handle timers in Gambit at all), the trick to run it in the same OS thread would be required.  I don't know, from the top of my head, whether and how SDL does idle events.<br>


<br></div>A fancier approach would be to look up the implementation of ##repl-debug-main and try and see if there are any hooks by which the trick I mentioned in the previous message could be enabled.  If there are not, you could try running your own modified version of ##repl-debug-main (factoring out the hooks that would enable the just-wait-for-as-long-as-the-REPL-is-doing-actual-work trick would be a nice contribution to gambit IMHO).<br>


</div><br></blockquote><div><br>Thanks all for your insights and help :)<br><br>I found a solution, which is very simple: just create the REPL thread, then create the SDL Cocoa draw loop callback, and finally let the main function return. Since the callback is going to 
be called repeatedly by iOS, the REPL thread will be resumed since it 
didn't terminate. The key insight is realizing that the current thread in 
Scheme returns to C, but the other threads will continue their execution
 as soon as you come back to Scheme. <br><br></div><div>It works now, with both custom application loops and event-loop hooks models.<br></div></div></div></div>