replace C-style concurrent initialization of statics

C++ statics are thread-safe as is and are usually implemented more
efficiently. Besides, `volatile` is likely misused here anyway.
This commit is contained in:
mjk 2021-03-21 18:44:36 +00:00 committed by LAGonauta
parent 8988b77d57
commit 7b6f3ea9f6

View file

@ -7,17 +7,12 @@
GType \ GType \
type_name ## _get_type (void) \ type_name ## _get_type (void) \
{ \ { \
static volatile gsize g_define_id__volatile = 0; \ static constexpr GEnumValue v[] = { \
if (g_once_init_enter (&g_define_id__volatile)) \
{ \
static const GEnumValue v[] = { \
values \ values \
{ 0, NULL, NULL }, \ { 0, NULL, NULL }, \
}; \ }; \
GType g_define_id = g_enum_register_static (g_intern_static_string (#TypeName), v); \ static const auto enum_type_id = g_enum_register_static (g_intern_static_string (#TypeName), v); \
g_once_init_leave (&g_define_id__volatile, g_define_id); \ return enum_type_id; \
} \
return g_define_id__volatile; \
} }
WINRT_GLIB_DEFINE_ENUM_TYPE (winrtWindowsUINotificationsToastDismissalReason, winrt_windows_ui_notifications_toast_dismissal_reason, WINRT_GLIB_DEFINE_ENUM_TYPE (winrtWindowsUINotificationsToastDismissalReason, winrt_windows_ui_notifications_toast_dismissal_reason,