From 2abb67e4991348c20560eed9ba02cd0fc795307c Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Tue, 27 Jul 2021 06:53:29 +0200 Subject: [PATCH] initialize NodeBuilder registry by IIFE instead of double lock pattern (#6753) --- ngraph/test/util/visitor.hpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ngraph/test/util/visitor.hpp b/ngraph/test/util/visitor.hpp index 27955068f1eca5..8c443c0aa43e3c 100644 --- a/ngraph/test/util/visitor.hpp +++ b/ngraph/test/util/visitor.hpp @@ -393,20 +393,14 @@ namespace ngraph AttributeVisitor& get_node_loader() { return *this; } static FactoryRegistry& get_ops() { - static std::shared_ptr> registry; - static std::mutex init_guard; - if (!registry) - { - std::lock_guard guard(init_guard); - if (!registry) - { - registry = std::make_shared>(); -#define NGRAPH_OP(NAME, NAMESPACE, VERSION) registry->register_factory(); + static FactoryRegistry registry = [] { + FactoryRegistry registry; +#define NGRAPH_OP(NAME, NAMESPACE, VERSION) registry.register_factory(); #include "op_version_tbl.hpp" #undef NGRAPH_OP - } - } - return *registry; + return registry; + }(); + return registry; } protected: