diff --git a/xacc/service/xacc_service.cpp b/xacc/service/xacc_service.cpp index 079b3c9af..b3d982437 100644 --- a/xacc/service/xacc_service.cpp +++ b/xacc/service/xacc_service.cpp @@ -20,8 +20,7 @@ using namespace cxxopts; namespace xacc { // class ServiceRegistry; bool serviceAPIInitialized = false; -std::shared_ptr serviceRegistry = - std::make_shared(); +std::unique_ptr serviceRegistry; void addPluginSearchPath(const std::string path) { serviceRegistry->appendSearchPath(path); @@ -44,6 +43,7 @@ void ServiceAPI_Initialize(int argc, char **argv) { rootPath = vm["xacc-root-path"].as(); } + serviceRegistry = std::make_unique(); try { serviceRegistry->initialize(rootPath); } catch (std::exception &e) { @@ -60,6 +60,7 @@ void ServiceAPI_Finalize() { if (serviceAPIInitialized) { serviceAPIInitialized = false; serviceRegistry->finalize(); + serviceRegistry.release(); } } diff --git a/xacc/service/xacc_service.hpp b/xacc/service/xacc_service.hpp index 0c564fb19..85665dc68 100644 --- a/xacc/service/xacc_service.hpp +++ b/xacc/service/xacc_service.hpp @@ -18,7 +18,7 @@ namespace xacc { -extern std::shared_ptr serviceRegistry; +extern std::unique_ptr serviceRegistry; extern bool serviceAPIInitialized; void ServiceAPI_Initialize(int argc, char **argv);