Re: glib >= 2.31.0 Threads and Mutexes



On 10/31/2011 10:26 AM, martinbts gmx net wrote:
> Hello list!
> 
> There was a change in the threads and mutexes API in glib starting with version 2.31, see http://git.gnome.org/browse/glib/tree/NEWS. Especially g_thread_init(), g_thread_create(), g_mutex_new() and g_mutex_free() are gone.  I replaced those as follows:
> 
> - made g_thread_init conditional, as demonstrated in https://bugs.freedesktop.org/show_bug.cgi?id=42036.

g_thread_init() has been unnecessary since glib 2.24 in any program that
uses GObjects. NM claims to only require glib 2.18 right now... I don't
know if that's true or not.

> - g_mutex_new() replaced by static declarations of GMutex-es and (conditionally) passing their references where g_mutex_new() used to be called

The right replacement is to replace

  GMutex *foo;
  ...
  foo = g_mutex_new ();
  ...
  g_mutex_lock (foo);
  ...
  g_mutex_free (foo);

with:

  GMutex foo;
  ...
  g_mutex_init (&foo);
  ...
  g_mutex_lock (&foo);
  ...
  g_mutex_clear (&foo);


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