Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions Sources/IssueReporting/Internal/LockIsolated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ final class LockIsolated<Value>: @unchecked Sendable {
init(_ value: sending Value) {
self._value = value
}
@usableFromInline
func withLock<T>(
_ operation: sending (inout sending Value) throws -> sending T
) rethrows -> sending T {
lock.lock()
defer { lock.unlock() }
var value = _value
defer { _value = value }
return try operation(&value)
}
#if compiler(>=6.3)
@usableFromInline
func withLock<T>(
_ operation: sending (inout sending Value) throws -> sending T
) rethrows -> sending T {
lock.lock()
defer { lock.unlock() }
var value = _value
defer { _value = value }
return try operation(&value)
}
#else
@usableFromInline
func withLock<T>(
_ operation: @Sendable (inout Value) throws -> T
) rethrows -> sending T {
lock.lock()
defer { lock.unlock() }
var value = _value
defer { _value = value }
return try operation(&value)
}
#endif
}
Loading