From ec43179de753c6d8e9cf2a0b89169c3671070b15 Mon Sep 17 00:00:00 2001 From: zamderax Date: Mon, 9 Dec 2024 07:57:19 -0800 Subject: [PATCH] Lock is now NIOLock --- Sources/Casbin/Cache/MemoryCache.swift | 2 +- Sources/Casbin/Core/Core.swift | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Casbin/Cache/MemoryCache.swift b/Sources/Casbin/Cache/MemoryCache.swift index 7fc2d1c..24ce039 100644 --- a/Sources/Casbin/Cache/MemoryCache.swift +++ b/Sources/Casbin/Cache/MemoryCache.swift @@ -55,7 +55,7 @@ final class LruCache { } 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() diff --git a/Sources/Casbin/Core/Core.swift b/Sources/Casbin/Core/Core.swift index b6058ac..eb7b366 100644 --- a/Sources/Casbin/Core/Core.swift +++ b/Sources/Casbin/Core/Core.swift @@ -47,7 +47,7 @@ extension Enforcer { self.core.storage.locks } - public var sync: Lock { + public var sync: NIOLock { self.locks.main } @@ -86,15 +86,15 @@ 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(for key: Key.Type) -> Lock + public func lock(for key: Key.Type) -> NIOLock where Key: LockKey { self.main.lock() @@ -102,7 +102,7 @@ extension Enforcer { 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 }