Re: Threads and main-loops



Tristan Van Berkom wrote:
Russell Shaw wrote:
[...]

Hi,
Thanks, is clearer now. I needed to have a mental model (i think visual)
of threading and loop contexts to design the overall architecture of my app.


    Note that you can create multiple threads and run GMainLoops in each
thread, but its a little tricky.

Functions which create and manipulate event sources under the hood
need to be avoided (i.e. g_timeout_add, g_idle_add, g_io_add_watch) as
they assume the default GMainContext (which is OK if you intend to queue
events to the default GMainLoop from another thread), instead; you would
need to use the slightly more complex varients (i.e. g_idle_source_new
in conjunction with g_source_attatch et al).

Hi,
I want to make an app that can have multiple top-level windows open, each
of which contains a document being edited. If a user was half way thru
doing something in one document window, then clicks another document
window and does something there, then goes back to doing something in
the first window, i want the context of these windows to be maintained.
So, one application should give the illusion of multiple instances of a
simpler single-document application.

Could i do this by using a separate thread for each document window,
where each thread has its own g_main_loop and g_main_context ?
Will gtk widgets work properly without needing locking and mutexes etc?
I need to use one thread per window because the execution point goes
around a complicated super loop, and each document/window has one.

Even tho this isn't window-in-window, is this classed as MDI, or SDI?

I want one main menu that can control settings common to all the
open windows/documents.



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