Skip to content

Commit 10546f1

Browse files
committed
use std::call_once
1 parent ae1184d commit 10546f1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sycl/source/detail/xpti_registry.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010

11+
#include <mutex>
1112
#include <string>
1213
#include <unordered_set>
1314

@@ -33,10 +34,7 @@ class XPTIRegistry {
3334
public:
3435
void initializeFrameworkOnce() {
3536
#ifdef XPTI_ENABLE_INSTRUMENTATION
36-
if (!MInitialized) {
37-
xptiFrameworkInitialize();
38-
MInitialized = true;
39-
}
37+
std::call_once(MInitialized, [] { xptiFrameworkInitialize(); });
4038
#endif
4139
}
4240

@@ -65,7 +63,7 @@ class XPTIRegistry {
6563

6664
private:
6765
std::unordered_set<std::string> MActiveStreams;
68-
bool MInitialized = false;
66+
std::once_flag MInitialized;
6967
};
7068
} // namespace detail
7169
} // namespace sycl

0 commit comments

Comments
 (0)