Re: more mainloops in more threads?

On Tue, 2008-04-01 at 23:17 +0200, Roberto -MadBob- Guido wrote:
> And, as I can understand, there is no way to manage different lists of 
> handlers for different contexts (say: for different threads).
> I think Glib will need some low level revisions to match requirements for near 
> future computation models...

You understand wrongly.  You can have a separate glib main loop for any
thread, if you want.

Start the thread, get a GMainContext object (g_main_context_new()),
create a new GMainLoop with that context (g_main_loop_new()) and then
run the loop in that thread (g_main_loop_run()).

You can create main loop sources with g_idle_source_new(),
g_timeout_source_new(), g_child_watch_source_new() or a custom GSource
object and attach it to the GMainContext object you created, and it will
run in that thread.

glib is thread safe provide that you have called g_thread_init() first.

Read the documentation at


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