Re: Help with a multi-threaded application. Spot a crash.



Hi again Osmo,

On 31 May 2012 17:50, Osmo Antero <osmoma gmail com> wrote:
Jcupitt:
Ok, g_idle_add() seems to need protection by gdk_threads_enter() and
leave().
Ref:
http://developer.gnome.org/gdk/stable/gdk-Threads.html#gdk-threads-add-idle

That's out of date. g_idle_add() does not need any locking by you.

can do without. Anyway, an interesting suggestion to use the main-loop to
run a job-function or "thread". This "thread" have to compete with other
events like GUI-updates and key strokes.

Yes, you can't use the main thread for much computation, but it's fine
to just service events and do simple GUI changes. All drawing will be
serialised anyway, of course, so serialising slightly earlier will
hardly affect performance.

Additionally, having the guarantee that handlers cannot interfere with
each other makes your GUI code much simpler. You can manipulate your
model without worrying about locks. You only need to remember that
handlers can fire in (almost) any order.

John



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