From ee5a5046994532a3100ee0335bad9d5e48e9f768 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 31 Oct 2023 09:05:07 -0700 Subject: [PATCH] `LockIsolated.withValue` closure should be sendable --- Sources/ConcurrencyExtras/LockIsolated.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/ConcurrencyExtras/LockIsolated.swift b/Sources/ConcurrencyExtras/LockIsolated.swift index 8b53bc9..52b14b5 100644 --- a/Sources/ConcurrencyExtras/LockIsolated.swift +++ b/Sources/ConcurrencyExtras/LockIsolated.swift @@ -39,7 +39,7 @@ public final class LockIsolated: @unchecked Sendable { /// - Parameter operation: An operation to be performed on the the underlying value with a lock. /// - Returns: The result of the operation. public func withValue( - _ operation: (inout Value) throws -> T + _ operation: @Sendable (inout Value) throws -> T ) rethrows -> T { try self.lock.sync { var value = self._value @@ -93,15 +93,17 @@ extension LockIsolated where Value: Sendable { } } +@available(*, deprecated, message: "Lock isolated values should not be equatable") extension LockIsolated: Equatable where Value: Equatable { public static func == (lhs: LockIsolated, rhs: LockIsolated) -> Bool { - lhs.withValue { lhsValue in rhs.withValue { rhsValue in lhsValue == rhsValue } } + lhs.value == rhs.value } } +@available(*, deprecated, message: "Lock isolated values should not be hashable") extension LockIsolated: Hashable where Value: Hashable { public func hash(into hasher: inout Hasher) { - self.withValue { hasher.combine($0) } + hasher.combine(self.value) } }