Skip to content

Commit bb5059b

Browse files
authored
LockIsolated.withValue closure should be sendable (#13)
1 parent 390d011 commit bb5059b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/ConcurrencyExtras/LockIsolated.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class LockIsolated<Value>: @unchecked Sendable {
3939
/// - Parameter operation: An operation to be performed on the the underlying value with a lock.
4040
/// - Returns: The result of the operation.
4141
public func withValue<T: Sendable>(
42-
_ operation: (inout Value) throws -> T
42+
_ operation: @Sendable (inout Value) throws -> T
4343
) rethrows -> T {
4444
try self.lock.sync {
4545
var value = self._value
@@ -93,15 +93,17 @@ extension LockIsolated where Value: Sendable {
9393
}
9494
}
9595

96+
@available(*, deprecated, message: "Lock isolated values should not be equatable")
9697
extension LockIsolated: Equatable where Value: Equatable {
9798
public static func == (lhs: LockIsolated, rhs: LockIsolated) -> Bool {
98-
lhs.withValue { lhsValue in rhs.withValue { rhsValue in lhsValue == rhsValue } }
99+
lhs.value == rhs.value
99100
}
100101
}
101102

103+
@available(*, deprecated, message: "Lock isolated values should not be hashable")
102104
extension LockIsolated: Hashable where Value: Hashable {
103105
public func hash(into hasher: inout Hasher) {
104-
self.withValue { hasher.combine($0) }
106+
hasher.combine(self.value)
105107
}
106108
}
107109

0 commit comments

Comments
 (0)