From 5e0ed5209fffe925dbcc5746a7cfad8ef8db52e7 Mon Sep 17 00:00:00 2001 From: Ryu0118 Date: Sun, 1 Oct 2023 20:17:41 +0900 Subject: [PATCH] remove lock instance --- Sources/SimplexArchitecture/StateContainer.swift | 3 +-- Sources/SimplexArchitecture/Store/Store+send.swift | 7 ------- Sources/SimplexArchitecture/Store/Store.swift | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Sources/SimplexArchitecture/StateContainer.swift b/Sources/SimplexArchitecture/StateContainer.swift index 6a71187..9e6595f 100644 --- a/Sources/SimplexArchitecture/StateContainer.swift +++ b/Sources/SimplexArchitecture/StateContainer.swift @@ -1,8 +1,7 @@ import Foundation import XCTestDynamicOverlay -/// StateContainer is not thread-safe. Therefore, StateContainer must use NSLock or NSRecursiveLock for exclusions when changing values. -/// In Store, NSRecursiveLock is used for exclusions when executing the `reduce(into:action)`. +/// StateContainer is not thread-safe. StateContainer must be accessed from MainActor. @dynamicMemberLookup public final class StateContainer { public var reducerState: Target.Reducer.ReducerState { diff --git a/Sources/SimplexArchitecture/Store/Store+send.swift b/Sources/SimplexArchitecture/Store/Store+send.swift index e64a23e..fd8f234 100644 --- a/Sources/SimplexArchitecture/Store/Store+send.swift +++ b/Sources/SimplexArchitecture/Store/Store+send.swift @@ -118,13 +118,6 @@ extension Store { } } - @inlinable - func withLock(_ operation: () throws -> T) rethrows -> T { - lock.lock() - defer { lock.unlock() } - return try operation() - } - func makeSend(for container: StateContainer) -> Send { Send( sendAction: { [weak self] action in diff --git a/Sources/SimplexArchitecture/Store/Store.swift b/Sources/SimplexArchitecture/Store/Store.swift index 01b718b..04217f6 100644 --- a/Sources/SimplexArchitecture/Store/Store.swift +++ b/Sources/SimplexArchitecture/Store/Store.swift @@ -16,7 +16,6 @@ public final class Store { // Buffer to store Actions recurrently invoked through SideEffect in a single Action sent from View @TestOnly var sentFromEffectActions: [ActionTransition] = [] - @usableFromInline let lock = NSRecursiveLock() @usableFromInline var pullbackAction: ((Reducer.Action) -> Void)? @usableFromInline var pullbackReducerAction: ((Reducer.ReducerAction) -> Void)?