File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
src/plugins/intel_npu/src/utils
include/intel_npu/utils/zero Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ class ZeroApi {
7878
7979 ~ZeroApi () = default ;
8080
81- static const std::shared_ptr<ZeroApi>& getInstance ();
81+ static const std::shared_ptr<ZeroApi> getInstance ();
8282
8383#define symbol_statement (symbol ) decltype (&::symbol) symbol;
8484 symbols_list ();
Original file line number Diff line number Diff line change 44
55#include " intel_npu/utils/zero/zero_api.hpp"
66
7+ #include < mutex>
8+
79#include " openvino/util/file_util.hpp"
810#include " openvino/util/shared_object.hpp"
911
@@ -49,8 +51,16 @@ ZeroApi::ZeroApi() {
4951#undef symbol_statement
5052}
5153
52- const std::shared_ptr<ZeroApi>& ZeroApi::getInstance () {
53- static std::shared_ptr<ZeroApi> instance = std::make_shared<ZeroApi>();
54+ const std::shared_ptr<ZeroApi> ZeroApi::getInstance () {
55+ static std::mutex mutex;
56+ static std::weak_ptr<ZeroApi> weak_instance;
57+
58+ std::lock_guard<std::mutex> lock (mutex);
59+ auto instance = weak_instance.lock ();
60+ if (!instance) {
61+ instance = std::make_shared<ZeroApi>();
62+ weak_instance = instance;
63+ }
5464 return instance;
5565}
5666
You can’t perform that action at this time.
0 commit comments