Skip to content

Commit

Permalink
Lock is now NIOLock
Browse files Browse the repository at this point in the history
  • Loading branch information
zamderax committed Dec 9, 2024
1 parent 12a3a31 commit ec43179
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/Casbin/Cache/MemoryCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class LruCache<Key:Hashable,Value> {
}
private var storage:[Key:ListNode] = [:]
var capacity = 0
private var lock:Lock
private var lock: NIOLock

/// head's nextNode is the actual first node in the Double Linked-list.
private var head = ListNode()
Expand Down
10 changes: 5 additions & 5 deletions Sources/Casbin/Core/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Enforcer {
self.core.storage.locks
}

public var sync: Lock {
public var sync: NIOLock {
self.locks.main
}

Expand Down Expand Up @@ -86,23 +86,23 @@ extension Enforcer {
}

public final class Locks {
public let main: Lock
var storage: [ObjectIdentifier: Lock]
public let main: NIOLock
var storage: [ObjectIdentifier: NIOLock]

init() {
self.main = .init()
self.storage = [:]
}

public func lock<Key>(for key: Key.Type) -> Lock
public func lock<Key>(for key: Key.Type) -> NIOLock
where Key: LockKey
{
self.main.lock()
defer { self.main.unlock() }
if let existing = self.storage[ObjectIdentifier(Key.self)] {
return existing
} else {
let new = Lock()
let new = NIOLock()
self.storage[ObjectIdentifier(Key.self)] = new
return new
}
Expand Down

0 comments on commit ec43179

Please sign in to comment.