Re: instance-private-data issue



On 6 Aug 2003, Owen Taylor wrote:

> * For normal mutexes, static mutexes are more efficient than
>   dynamically allocated mutexes and a lot easier to manage.
>   That's why we use them in most places in GLib for locking
>   global resources.

how can static mutexes be more efficient if:
  #define g_static_mutex_lock(mutex) \
      g_mutex_lock (g_static_mutex_get_mutex (mutex))
their implementation is based on normal dynamic mutex functions?

for some configurations, g_static_mutex_get_mutex() may even go through
a single glib-global lock used to protect all static mutexes.

as for being easier to manage, that boils down to:
  G_LOCK_DEFINE_STATIC (type_lock);
vs:
  static GMutex *type_lock;
  init { type_lock = g_mutex_new (); }
which is no problem if you have an init function, here, g_type_init().

> Regards,
> 					Owen
>

---
ciaoTJ




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