g_type_register_static and thread-safety

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

 



Hello,

Almost all get_type() functions contain code
like

GType
whatever_get_type (void)
{
  static GType object_type = 0;

  if (!object_type)
    {
      static const GTypeInfo object_info =
      { ...  };

      object_type = g_type_register_static (G_TYPE_OBJECT, "Whatever", &object_info, 0);
    }

  return object_type;
}

Is this thread-safe?  I cannot see any guards in
g_type_register_static that prevent a second type-node from
being allocated in the obvious race condition...

Am i missing something?
The gtype docuemtnation does not mention thread-safety of this function.

thanks,
dave


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux