On Wed, Dec 7, 2011 at 2:30 AM,  <jcup...@gmail.com> wrote:
> 2011/12/6 Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -
> <marcelo.va...@claro.com.br>:
>>        Do I need to call g_thread_init() manually before calling g_mutex_new 
>> (), in a glib only application? Or is it auto called by default when I call 
>> g_type_init() and therefore I don't need to do it?
>
> Older versions of glib had optional threading support, so you needed
> to call g_thread_init() yourself.
>
> Newer versions (in the last 12 months or so? can't remember, but about
> that) have made thread support required and the threading system is
> now inited for you as part of glib startup.
>
> It's harmless to call g_thread_init() more than once.

Out of curiosity, what is "glib startup" ?

Do you mean as a part of g_type_init() ?

Or, can glib programs which don't make use of GObject use
threads at all ? Must _those_ programs still call g_thread_init()
before using threads ?

It seems that the pthread library itself requires at least that pthread_init()
be called once before using threads, is it called implicitly by every
function that might require threads ? (like g_mutex_init() ?)

Speaking of which, I just stumbled on some really odd documentation
for g_mutex_init(), it says there:

   "It is not necessary to initialize a mutex that has been created
that has been statically allocated."

Anyone care to mention what that means ? Mustn't a mutex at least be
zero initialized if
declared on the stack ? i.e. GMutex my_mutex = { 0, }; ?

Cheers,
         -Tristan

>
> John
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
  • mutex doubt Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -
    • Re: mutex ... jcupitt
      • Re: mu... Tristan Van Berkom
        • Re... Emmanuele Bassi
          • ... Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -
            • ... Tristan Van Berkom
              • ... Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -
        • RE... Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -
          • ... Marcelo Elias Del Valle - SYSMAP SOLUTIONS - Claro MA-SP -

Reply via email to