GNOME Bugzilla – Bug 627240
add G_DEFINE_QUARK
Last modified: 2012-08-28 12:38:28 UTC
As requested in bug 449565 comment 4. Since the primary use of it seems to be error domains, maybe name it G_DEFINE_ERROR_DOMAIN instead? Also, a G_DEFINE_DBUS_ERROR_DOMAIN (?) variant that uses g_dbus_error_register_error_domain() would be useful.
definitely +1 for G_DEFINE_ERROR_DOMAIN. we could also integrate it with G_DEFINE_ENUM_TYPE (bug 627241) to get a macro like: G_DEFINE_ERROR_DOMAIN (MyTypeError, my_type_error, { MY_ERROR_CODE_1, "MY_ERROR_CODE_1", "code-1" }, { MY_ERROR_CODE_2, "MY_ERROR_CODE_2", "code-2" }); would semantically distinguish enumerations from error domains and codes.
Uhm... one small comment on the way it was implemented (702b44886572c657d552f3ec15e9794acd4265e5): Quarks are threadsafe, and if two threads try to register a quark for the same string at the same time, they get the same quark. This means that g_once_init_enter, and the associated locking and atomic access, is not necessary.
thats true. but going into g_quark_from_string takes a global lock ever time, as opposed to the local locking thats happening here. Might still not be worth it, I haven't measured it