Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions Sources/Cache/Cache/Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Foundation
open class Cache<Key: Hashable, Value>: Cacheable, @unchecked Sendable {

/// Lock to synchronize the access to the cache dictionary.
fileprivate var lock: NSLock
/// Using NSRecursiveLock to prevent re-entrant lock deadlocks with @Published property wrapper
fileprivate var lock: NSRecursiveLock

#if os(Linux) || os(Windows)
fileprivate var cache: [Key: Value] = [:]
Expand All @@ -31,7 +32,7 @@ open class Cache<Key: Hashable, Value>: Cacheable, @unchecked Sendable {
- Parameter initialValues: An optional dictionary of initial key-value pairs.
*/
required public init(initialValues: [Key: Value] = [:]) {
lock = NSLock()
lock = NSRecursiveLock()
cache = initialValues
}

Expand Down
Loading
Loading