Re: Is g_source_remove threadsafe?
- From: Alexander Larsson <alexl redhat com>
- To: Owen Taylor <otaylor redhat com>
- Cc: Tim Janik <timj gtk org>, gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: Is g_source_remove threadsafe?
- Date: Fri, 16 Nov 2007 14:38:18 +0100
On Fri, 2007-11-16 at 08:30 -0500, Owen Taylor wrote:
> On Fri, 2007-11-16 at 14:12 +0100, Alexander Larsson wrote:
> > On Fri, 2007-11-16 at 14:04 +0100, Tim Janik wrote:
> > > On Fri, 16 Nov 2007, Alexander Larsson wrote:
> > >
> > > > I'm doing something where i have one thread queueing idles and timeouts
> > > > in a thread, and the main loop consumes this. In some cases i want to
> > > > remove the sources (to replace a timeout with an idle). However:
> > >
> > > > Am I missing something obvious here?
> > >
> > > simply use g_source_remove (id) instead.
> >
> > Eh, thats the call I talked about.
>
> I think Tim meant g_source_destroy() ... if you have a reference to a
> source, it's not going to vanish from beneath you in a different thread
> because you return FALSE from the source function.
Yeah, thats what I meant by the last statement in my mail ("I guess I
will have to keep the actual source object around").
> The ID versions of the functions are basically just there for backwards
> compat: they are a bit slower, and aren't completely protected against
> ID wraparound.
Most people still use them though, because it involves less typing due
to the helper functions like g_idle_add().
> While I don't really consider
> g_source_remove(some_id_that_I_might_already_have_removed) 100% valid,
> the docs do imply that it is legal, so perhaps it would be worth fixing
> up that case (say, by having a referencing internal variant of
> find_source_by_id().)
Yeah, the docs does seem to impy these things are legal.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]