Le quartidi 24 ventôse, an CCXIV, Michael Ekstrand a écrit : > Wouldn't it work to just register your callback as an idle handler? > Have it return FALSE, so it doesn't get run again, but it will be run > in the main loop. You are right, it works. Thanks. I had thought of it, but I had immediately dismissed it, for the following reason: the main loop is essentially a poll() system call, and I did not see how the second thread could cause it to finish. So, I thought, the idle function would be delayed until something else happens. But you making the suggestion convinced me to actually try it, and I see it works. And strace show me how actually it works: it uses the self-pipe trick to wake the poll. Now, I have browsed the source, and found the existence of g_main_context_wakeup. I would suggest to add a few words to the descriptsion of that function, making sure the word "thread" appears. The current description is: # If context is currently waiting in a poll(), interrupt the poll(), and # continue the iteration process. I suggest to add: # This is especially (only?) useful in threaded programs, to wake a context # from another thread. Note that a context is automatically woken when a new # source is added. Regards, -- Nicolas George
Attachment:
signature.asc
Description: Digital signature