Skip to content

Commit 8b66b22

Browse files
authored
Fix Windows build break. (#2935)
Use `withLockPrimitive` to access the underlying lock. ### Motivation: The current method of accessing the lock doesn't build. This fixes bug #2934. ### Modifications: Access the lock via `withLockPrimitive`. ### Result: Now it builds! :)
1 parent ff98c93 commit 8b66b22

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Sources/NIOConcurrencyHelpers/lock.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,17 @@ public final class ConditionLock<T: Equatable> {
229229
}
230230

231231
let dwWaitStart = timeGetTime()
232-
if !SleepConditionVariableSRW(
233-
self.cond,
234-
self.mutex._storage.mutex,
235-
dwMilliseconds,
236-
0
237-
) {
232+
let result = self.mutex.withLockPrimitive { mutex in
233+
SleepConditionVariableSRW(self.cond, mutex, dwMilliseconds, 0)
234+
}
235+
if !result {
238236
let dwError = GetLastError()
239237
if dwError == ERROR_TIMEOUT {
240238
self.unlock()
241239
return false
242240
}
243241
fatalError("SleepConditionVariableSRW: \(dwError)")
244242
}
245-
246243
// NOTE: this may be a spurious wakeup, adjust the timeout accordingly
247244
dwMilliseconds = dwMilliseconds - (timeGetTime() - dwWaitStart)
248245
}

0 commit comments

Comments
 (0)