[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [lgi] problem with GLib this time.
- From: Laurent FAILLIE <l_faillie@...>
- Date: Mon, 9 Jul 2012 05:19:00 -0700 (PDT)
Thanks for the explanation, I made it working. I have a window with both a background counter and [+] and [Reset] button that interact with it :)
It's incredible how fast is Lua/Lgi learning curve :D
> It is possible, but I have not tried it yet myself; look at g_main_context_iteration() and/or gtk_main_iteration_do() APIs.
I googled to
but I didn't tried yet.
> Note Lua's coroutines
> can be really helpful here, because you can make ImDoingSomeHardWork() running as coroutine, spiced with coroutine.yield() at 'strategic'
places. Then you
> pass coroutine instance (instead of function) to GLib.idle_add(), and voila, coroutine is periodically resumed when GLib's mainloop has nothing else to do.
I didn't tried yet co-routines. But when you said "resumed", it means the co-routine will restart from where it was interrupted and I don't have to manage context or such. I mean like an OS task is interrupted by an IRQ ?
I'll have to learn also how to interact with the co-routine. Signal ? Semaphore ???