mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor(mobile): introduce image request registry on iOS (#27486)
* 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>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user