mirror of
https://github.com/immich-app/immich.git
synced 2026-04-09 02:32:00 -04:00
* refactor: replace DispatchQueue + DispatchSemaphore with OperationQueue for image processing * implement RequestRegistry and UnfairLock for managing cancellable requests * implement requests registry for local and remote image processing * remove Cancellable protocol and cancel method from request registry * use mutex --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
15 lines
364 B
Swift
15 lines
364 B
Swift
import Foundation
|
|
|
|
struct RequestRegistry<T: AnyObject & Sendable>: ~Copyable, Sendable {
|
|
private let requests = Mutex<[Int64: T]>([:])
|
|
|
|
func add(requestId: Int64, request: T) {
|
|
requests.withLock { $0[requestId] = request }
|
|
}
|
|
|
|
@discardableResult
|
|
func remove(requestId: Int64) -> T? {
|
|
requests.withLock { $0.removeValue(forKey: requestId) }
|
|
}
|
|
}
|