Re: main loop & asynchronous queues
- From: Chris Vine <chris cvine freeserve co uk>
- To: Thomas Stover <thomas wsinnovations com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: main loop & asynchronous queues
- Date: Thu, 24 Sep 2009 23:57:17 +0100
On Thu, 24 Sep 2009 14:32:30 -0500
Thomas Stover <thomas wsinnovations com> wrote:
[snip]
For anyone in the future searching around for more info on this
topic, here is a variation of the gtk hello world program I was doing
some experiments with. My main question at this point to anyone who
might know is, should the idle source get dereferenced / freed
somehow? My other question is g_source_attach() working on another
thread's GMainContext with atomic operations, will it possibly have
to block for access, or I'm I not doing this in a thread safe way?
Since you call g_thread_init(), g_source_attach() is thread safe so
that is fine. However, to get the GSource objects to clean up when
they are finished with you need to call g_source_unref() after
g_source_attach() (g_source_attach() increments the reference count).
The main loop has a mutex protecting it when sources are added or
removed or callbacks are read for dispatch. That might block
momentarily if there is contention but nothing that you would notice.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]