Re: Is g_source_remove threadsafe?



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.

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.

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().) 


- Owen

Attachment: signature.asc
Description: This is a digitally signed message part



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