Skip to content

Commit

Permalink
Fix concurrency warnings in CoreImageFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed May 2, 2024
1 parent b2c3384 commit 72fd1dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/Nuke/Internal/Atomic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation

final class Atomic<T: Sendable>: @unchecked Sendable {
final class Atomic<T>: @unchecked Sendable {
private var _value: T
private let lock: os_unfair_lock_t

Expand Down
7 changes: 6 additions & 1 deletion Sources/Nuke/Processing/ImageProcessors+CoreImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ extension ImageProcessors {

/// A default context shared between all Core Image filters. The context
/// has `.priorityRequestLow` option set to `true`.
public static var context = CIContext(options: [.priorityRequestLow: true])
public static var context: CIContext {
get { _context.value }
set { _context.value = newValue }
}

private static let _context = Atomic(value: CIContext(options: [.priorityRequestLow: true]))

static func applyFilter(named name: String, parameters: [String: Any] = [:], to image: PlatformImage) throws -> PlatformImage {
guard let filter = CIFilter(name: name, parameters: parameters) else {
Expand Down

0 comments on commit 72fd1dd

Please sign in to comment.