After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 627240 - add G_DEFINE_QUARK
add G_DEFINE_QUARK
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-08-18 08:32 UTC by Christian Persch
Modified: 2012-08-28 12:38 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Persch 2010-08-18 08:32:56 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.
Comment 1 Emmanuele Bassi (:ebassi) 2010-09-30 11:07:23 UTC
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.
Comment 2 Giovanni Campagna 2012-08-28 11:38:21 UTC
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.
Comment 3 Matthias Clasen 2012-08-28 12:38:28 UTC
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