Skip to content

Commit 5134c21

Browse files
authored
Merge pull request #70767 from al45tair/eng/PR-119739594-5.10
[Threading] Fix C11 once implementation to not rely on lock recursion.
2 parents 5b17976 + 0fa5914 commit 5134c21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Threading/C11.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class C11ThreadingHelper {
4343
void once_unlock() { SWIFT_C11THREADS_CHECK(mtx_unlock(&onceMutex_)); }
4444
void once_broadcast() { SWIFT_C11THREADS_CHECK(cnd_broadcast(&onceCond_)); }
4545
void once_wait() {
46-
SWIFT_C11THREADS_CHECK(mtx_lock(&onceMutex_));
46+
// The mutex must be locked when this function is entered. It will
47+
// be locked again before the function returns.
4748
SWIFT_C11THREADS_CHECK(cnd_wait(&onceCond_, &onceMutex_));
48-
SWIFT_C11THREADS_CHECK(mtx_unlock(&onceMutex_));
4949
}
5050
};
5151

0 commit comments

Comments
 (0)