We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5b9435c commit dfe78dfCopy full SHA for dfe78df
1 file changed
unittests/CppInterOp/Utils.cpp
@@ -35,8 +35,12 @@ struct DispatchInitializer {
35
DispatchInitializer(DispatchInitializer&&) noexcept = default;
36
DispatchInitializer& operator=(DispatchInitializer&&) noexcept = default;
37
};
38
-// FIXME: Make this threadsafe by moving it as a function static.
39
-DispatchInitializer g_dispatch_init;
+// Thread-safe initialization using function-local static
+static DispatchInitializer& GetDispatchInitializer() {
40
+ static DispatchInitializer instance;
41
+ return instance;
42
+}
43
+static DispatchInitializer& g_dispatch_init = GetDispatchInitializer();
44
} // namespace
45
#endif
46
0 commit comments