[gambit-list] Gambit and event-based systems

Álvaro Castro-Castilla alvaro.castro.castilla at gmail.com
Fri Aug 8 07:02:46 EDT 2014


On Fri, Aug 8, 2014 at 11:56 AM, Álvaro Castro-Castilla <
alvaro.castro.castilla at gmail.com> wrote:

>
> On Fri, Aug 8, 2014 at 1:19 AM, Estevo <euccastro at gmail.com> wrote:
>
>> 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.
>>
>> 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).
>>
>>
> Thanks all for your insights and help :)
>
> 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.
>
> It works now, with both custom application loops and event-loop hooks
> models.
>


After all this, folks at SDL list just told me that this is actually a bug
in the README, and you don't need the callback method any longer. You can
take full control of the loop at the moment. The only reason this was
necessary was for interaction with the Game Center, but apparently it isn't
as of now.

Well, at least I learnt something about Gambit threads - FFI interaction.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20140808/54e93000/attachment.htm>


More information about the Gambit-list mailing list