Is GLIB thread safe?



Hi all,

I'm writing a COM program on windows but I'm not quite familiar with C++.
thus I decided to use mostly C instead and I want to use GLIB in it.

But I got one problem.  Is GLIB thread safe?

I read some code, such as GArray.   There is no thread protection of a
GArray APIs.
So if more than one thread call these APIs on the same GArray variable,
there might be problems.  AS multi-core processors becoming popular,
this situations is
very possible.

But I found these lines in GLIB manual:

              If you use GLib from more than one thread, you must
initialize the thread system by calling g_thread_init().

And this:

              --disable-threads and --enable-threads.   Do not compile
GLib to be multi thread safe. GLib will be slightly faster then.

I don't quite understand.  Is there any thread protection hidden in
GLib source code that I didn't find?

Thanks!


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