Is g_source_unref thread-safe?
Recently I read some code of glib. And I have some questions about g_source_unref
. Is the following sequence possible?
- Thread 0 calls
g_source_unref
. During calling finalize callback of the source, thread 0 is turned to waitable. At the moment, the refenrence count of the source is 1, and the context is not locked; - Thread 1 calls and finishs
g_source_unref
, and the resource of the source has been freed; - Thread 0 starts to run again, and finish the rest logic of
g_source_unref
.
So is g_source_unref thread-safe? Do the users need an external lock to protect it?