lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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
while (gtk_events_pending())
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 ???