From 7b6f3ea9f619e39a5f46c4fa37f4715693437b50 Mon Sep 17 00:00:00 2001 From: mjk Date: Sun, 21 Mar 2021 18:44:36 +0000 Subject: [PATCH] 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. --- .../api/src/gobject/winrt-enums.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/windows-notification/api/src/gobject/winrt-enums.cpp b/plugins/windows-notification/api/src/gobject/winrt-enums.cpp index 2dde995f..7038c730 100644 --- a/plugins/windows-notification/api/src/gobject/winrt-enums.cpp +++ b/plugins/windows-notification/api/src/gobject/winrt-enums.cpp @@ -7,17 +7,12 @@ GType \ type_name ## _get_type (void) \ { \ - static volatile gsize g_define_id__volatile = 0; \ - if (g_once_init_enter (&g_define_id__volatile)) \ - { \ - static const GEnumValue v[] = { \ - values \ - { 0, NULL, NULL }, \ - }; \ - GType g_define_id = g_enum_register_static (g_intern_static_string (#TypeName), v); \ - g_once_init_leave (&g_define_id__volatile, g_define_id); \ - } \ - return g_define_id__volatile; \ + static constexpr GEnumValue v[] = { \ + values \ + { 0, NULL, NULL }, \ + }; \ + static const auto enum_type_id = g_enum_register_static (g_intern_static_string (#TypeName), v); \ + return enum_type_id; \ } WINRT_GLIB_DEFINE_ENUM_TYPE (winrtWindowsUINotificationsToastDismissalReason, winrt_windows_ui_notifications_toast_dismissal_reason,