Re: Is GObject threadsafe?!



On Wed, 2007-07-04 at 21:02 +0100, jcupitt gmail com wrote:
On 7/4/07, Tomasz Jankowski <tomcioj gmail com> wrote:
thread safe. It's very important to me, to know if I can safety use
g_object_set and g_object_get from many threads without providing my own
thread protection. I found something on web but it wasn't clear for me.

If thread A and thread B are manipulating the same object, then yes,
you need to synchronise them somehow (eg. with a lock).

If they are addressing separate objects, then there's no need to synchronise.

However, since the OP in his last posting referenced an obscure exchange
of e-mails on the developers' mailing list dealing with g_object_ref()
and g_object_unref(), it is worthing noting that with glib-2.8 onwards,
g_object_ref() and g_object_unref() are thread safe - so you can ref()
and unref() without corrupting the reference count.  But as far as I am
aware, that's it.

Chris





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