Skip to content

Commit cf242de

Browse files
committed
Add mutex guard
1 parent 444fbce commit cf242de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ void initPlugins() {
173173
}
174174

175175
Error olInit_impl() {
176+
// While the refcount increment ensures that only thread performs
177+
// initialization, we need to ensure that other threads are blocked until it
178+
// is completed - hence this mutex.
179+
static std::mutex Init{};
180+
std::lock_guard<std::mutex> Guard{Init};
181+
176182
if (++GlobalRefCount() == 1)
177183
initPlugins();
178184

0 commit comments

Comments
 (0)