We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f71b335 commit 13ddde5Copy full SHA for 13ddde5
sycl/plugins/unified_runtime/ur/ur.hpp
@@ -115,18 +115,13 @@ template <class T> struct ZeCache : private T {
115
//
116
using InitFunctionType = std::function<void(T &)>;
117
InitFunctionType Compute{nullptr};
118
- bool Computed{false};
119
- pi_mutex ZeCacheMutex;
+ std::once_flag Computed;
120
121
ZeCache() : T{} {}
122
123
// Access to the fields of the original T data structure.
124
T *operator->() {
125
- std::unique_lock<pi_mutex> Lock(ZeCacheMutex);
126
- if (!Computed) {
127
- Compute(*this);
128
- Computed = true;
129
- }
+ std::call_once(Computed, Compute, static_cast<T&>(*this));
130
return this;
131
}
132
};
0 commit comments