Skip to content

Commit e88edfc

Browse files
DanLiu2IntelWenjingKangIntel
authored andcommitted
fix comments2
1 parent 7de605e commit e88edfc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include <memory>
8+
#include <mutex>
89

910
#include "compiler.h"
1011
#include "intel_npu/common/filtered_config.hpp"
@@ -23,7 +24,15 @@ class VCLCompilerImpl final : public intel_npu::ICompiler {
2324
~VCLCompilerImpl() override;
2425

2526
static std::shared_ptr<VCLCompilerImpl> getInstance() {
26-
static std::weak_ptr<VCLCompilerImpl> compiler = std::make_shared<VCLCompilerImpl>();
27+
static std::mutex mutex;
28+
static std::weak_ptr<VCLCompilerImpl> weak_compiler;
29+
30+
std::lock_guard<std::mutex> lock(mutex);
31+
auto compiler = weak_compiler.lock();
32+
if (!compiler) {
33+
compiler = std::make_shared<VCLCompilerImpl>();
34+
weak_compiler = compiler;
35+
}
2736
return compiler;
2837
}
2938

0 commit comments

Comments
 (0)