Skip to content

Commit

Permalink
Fix Windows build break. (#2935)
Browse files Browse the repository at this point in the history
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! :)
  • Loading branch information
jeffdav authored Oct 19, 2024
1 parent ff98c93 commit 8b66b22
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Sources/NIOConcurrencyHelpers/lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,17 @@ public final class ConditionLock<T: Equatable> {
}

let dwWaitStart = timeGetTime()
if !SleepConditionVariableSRW(
self.cond,
self.mutex._storage.mutex,
dwMilliseconds,
0
) {
let result = self.mutex.withLockPrimitive { mutex in
SleepConditionVariableSRW(self.cond, mutex, dwMilliseconds, 0)
}
if !result {
let dwError = GetLastError()
if dwError == ERROR_TIMEOUT {
self.unlock()
return false
}
fatalError("SleepConditionVariableSRW: \(dwError)")
}

// NOTE: this may be a spurious wakeup, adjust the timeout accordingly
dwMilliseconds = dwMilliseconds - (timeGetTime() - dwWaitStart)
}
Expand Down

0 comments on commit 8b66b22

Please sign in to comment.