Skip to content

Commit 42bd408

Browse files
authored
feat: replace deprecated NIO Lock with NIOLock (#37)
1 parent cfaef1e commit 42bd408

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/Casbin/Cache/MemoryCache.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class LruCache<Key:Hashable,Value> {
5555
}
5656
private var storage:[Key:ListNode] = [:]
5757
var capacity = 0
58-
private var lock:Lock
58+
private var lock:NIOLock
5959

6060
/// head's nextNode is the actual first node in the Double Linked-list.
6161
private var head = ListNode()

Sources/Casbin/Core/Core.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension Enforcer {
4747
self.core.storage.locks
4848
}
4949

50-
public var sync: Lock {
50+
public var sync: NIOLock {
5151
self.locks.main
5252
}
5353

@@ -86,23 +86,23 @@ extension Enforcer {
8686
}
8787

8888
public final class Locks {
89-
public let main: Lock
90-
var storage: [ObjectIdentifier: Lock]
89+
public let main: NIOLock
90+
var storage: [ObjectIdentifier: NIOLock]
9191

9292
init() {
9393
self.main = .init()
9494
self.storage = [:]
9595
}
9696

97-
public func lock<Key>(for key: Key.Type) -> Lock
97+
public func lock<Key>(for key: Key.Type) -> NIOLock
9898
where Key: LockKey
9999
{
100100
self.main.lock()
101101
defer { self.main.unlock() }
102102
if let existing = self.storage[ObjectIdentifier(Key.self)] {
103103
return existing
104104
} else {
105-
let new = Lock()
105+
let new = NIOLock()
106106
self.storage[ObjectIdentifier(Key.self)] = new
107107
return new
108108
}

0 commit comments

Comments
 (0)