Skip to content

Commit

Permalink
Support Sendable #4
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Nov 1, 2022
1 parent d5dee34 commit 2778214
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Sources/UserDefaultsSnapshotLib/UserDefaultsObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import Foundation

open class UserDefaultsObject: Hashable {
open class UserDefaultsObject: Hashable, @unchecked Sendable {

public static func == (lhs: UserDefaultsObject, rhs: UserDefaultsObject) -> Bool {
lhs === rhs
Expand All @@ -33,6 +33,7 @@ open class UserDefaultsObject: Hashable {
return (modified[key] as? T) ?? (storage[key] as? T)
}

/// non-atomic
public func write<T: _UserDefaultsPrimitiveValueType>(value: T?, for key: String) {
guard let value = value else {
modified[key] = NSNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import Foundation

open class UserDefaultsPersistentStore<Schema: UserDefaultsObject>: UserDefaultsPersistentStoreBase {
open class UserDefaultsPersistentStore<Schema: UserDefaultsObject>: UserDefaultsPersistentStoreBase, @unchecked Sendable {

public let userDefaults: UserDefaults

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import Foundation

open class UserDefaultsPersistentStoreBase {
open class UserDefaultsPersistentStoreBase: @unchecked Sendable {

internal var subscribers: [UserDefaultsPersistentStoreSinkCancellable : () -> Void] = [:]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import Foundation

public final class UserDefaultsPersistentStoreSinkCancellable: Hashable {
public final class UserDefaultsPersistentStoreSinkCancellable: Hashable, @unchecked Sendable {

public static func == (lhs: UserDefaultsPersistentStoreSinkCancellable, rhs: UserDefaultsPersistentStoreSinkCancellable) -> Bool {
lhs === rhs
Expand Down
2 changes: 1 addition & 1 deletion Sources/UserDefaultsSnapshotLib/UserDefaultsSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation

@dynamicMemberLookup
public final class UserDefaultsSnapshot<Storage: UserDefaultsObject>: Hashable {
public final class UserDefaultsSnapshot<Storage: UserDefaultsObject>: Hashable, Sendable {

public static func == (lhs: UserDefaultsSnapshot, rhs: UserDefaultsSnapshot) -> Bool {
lhs === rhs
Expand Down

0 comments on commit 2778214

Please sign in to comment.