Skip to content

Commit a14ee62

Browse files
committed
Fix asserts to not be undefined
1 parent 5451f22 commit a14ee62

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

offload/include/PerThreadTable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ template <typename ObjectType> struct PerThread {
3535
PerThread &operator=(const PerThread &) = delete;
3636
PerThread &operator=(PerThread &&) = delete;
3737
~PerThread() {
38-
assert(Mutex.try_lock() &&
38+
assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
3939
"Cannot be deleted while other threads are adding entries");
4040
ThreadDataList.clear();
4141
}
@@ -64,7 +64,7 @@ template <typename ObjectType> struct PerThread {
6464
ObjectType &get() { return getThreadEntry(); }
6565

6666
template <class ClearFuncTy> void clear(ClearFuncTy ClearFunc) {
67-
assert(Mutex.try_lock() &&
67+
assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
6868
"Clear cannot be called while other threads are adding entries");
6969
for (std::shared_ptr<PerThreadData> ThreadData : ThreadDataList) {
7070
if (!ThreadData->ThreadEntry)
@@ -122,7 +122,7 @@ template <typename ContainerType, typename ObjectType> struct PerThreadTable {
122122
PerThreadTable &operator=(const PerThreadTable &) = delete;
123123
PerThreadTable &operator=(PerThreadTable &&) = delete;
124124
~PerThreadTable() {
125-
assert(Mutex.try_lock() &&
125+
assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
126126
"Cannot be deleted while other threads are adding entries");
127127
ThreadDataList.clear();
128128
}
@@ -186,7 +186,7 @@ template <typename ContainerType, typename ObjectType> struct PerThreadTable {
186186
}
187187

188188
template <class ClearFuncTy> void clear(ClearFuncTy ClearFunc) {
189-
assert(Mutex.try_lock() &&
189+
assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
190190
"Clear cannot be called while other threads are adding entries");
191191
for (std::shared_ptr<PerThreadData> ThreadData : ThreadDataList) {
192192
if (!ThreadData->ThreadEntry || ThreadData->NElements == 0)
@@ -212,7 +212,7 @@ template <typename ContainerType, typename ObjectType> struct PerThreadTable {
212212
}
213213

214214
template <class DeinitFuncTy> llvm::Error deinit(DeinitFuncTy DeinitFunc) {
215-
assert(Mutex.try_lock() &&
215+
assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
216216
"Deinit cannot be called while other threads are adding entries");
217217
for (std::shared_ptr<PerThreadData> ThreadData : ThreadDataList) {
218218
if (!ThreadData->ThreadEntry || ThreadData->NElements == 0)

0 commit comments

Comments
 (0)