Re: GSource object lifetime
- From: Thomas Stover <thomas wsinnovations com>
- To: Tadej BorovÅak <tadeboro gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GSource object lifetime
- Date: Tue, 03 May 2011 15:28:21 -0500
On Tue, 3 May 2011 22:06:02 +0200, Tadej BorovÅak <tadeboro gmail com>
wrote:
Hi.
I'm repetitively calling g_idle_source_new(), g_source_set_callback(),
g_source_attach() to get an idle callback to run in a separate thread.
The
callback in question always exits with FALSE.
Do you call g_source_unref() after attaching it?
Cheers, Tadej.
That did help (I think I still have an unrelated leak). I think a few
things could be made more clear in the docs (I'm not 100% sure I'm correct
either):
-A newly created source (from g_idle_source_new() ) has a reference count
of 1 not 0.
-g_source_attach() increases the reference count by 1
-returning FALSE in a source callback function detaches the source from
the source's attached main context, and decreases the reference count by 1
-Once a source has been detached by source callback function returning
FALSE, it can not be reattached g_source_attach(). An assertion error is
thrown. You can however, decrease the source's reference count down to 0 so
it will free itself, then create a fresh source.
--
www.thomasstover.com
FLYNN LIVES!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]