<div dir="ltr">Yes, I'll add that my response was meant for *one* main-loop-hoarding framework.  If you need to use more than one of these, things get hairy quickly and it's hard to make general suggestions without knowing the exact APIs you're given.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 7, 2014 at 3:26 PM, Hendrik Boom <span dir="ltr"><<a href="mailto:hendrik@topoi.pooq.com" target="_blank">hendrik@topoi.pooq.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, Aug 07, 2014 at 01:46:42PM +0200, Álvaro Castro-Castilla wrote:<br>
> Hi,<br>
><br>
> Specially in the mobile world, there are many platforms that force the<br>
> developer to think and code its applications around events. Sometimes this<br>
> is done with virtual functions or interface implementation, overriding<br>
> methods, or plain C-style callbacks.<br>
><br>
> The problem is, in any of these cases, generally the main loop is<br>
> controlled by the application. Since Gambit runs within the<br>
> ___setup(params) function, and then quits (expecting ___cleanup() to be<br>
> called), there is no way to easily adapt to this architecture except for<br>
> running in a separate thread and communicating through messages or shared<br>
> data.<br>
><br>
> Is there a better way to do this?<br>
<br>
</div>This is a fundamental flaw in event-loop systems -- that they have to<br>
take over control.  And they are usually not designed with the<br>
understanding that the whole application might need two such<br>
subsystems.<br>
<br>
Proper design would design an event-loop so that<br>
(a) the user can provide it with additional things to be done during<br>
each loop<br>
and/or<br>
(b) There's a function that can be called that performs one iteration<br>
of the event-loop, so that the user can have a loop that calls it<br>
frequently.<br>
<br>
Even so, there are probably things that are difficult, such as avoiding<br>
busy-waiting.  Sometimes separate threads are the best answer, if the<br>
synchronisation mecchanisms are fast enough.<br>
<span class="HOEnZb"><font color="#888888"><br>
-- hendrik<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</div></div></blockquote></div><br></div>