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 7f27ad3..fd8f234 100644 --- a/Sources/SimplexArchitecture/Store/Store+send.swift +++ b/Sources/SimplexArchitecture/Store/Store+send.swift @@ -73,9 +73,7 @@ extension Store { // If Unit Testing is in progress and an action is sent from SideEffect if _XCTIsTesting, let effectContext = EffectContext.id { let before = container.copy() - sideEffect = withLock { - reduce(container, action) - } + sideEffect = reduce(container, action) sentFromEffectActions.append( ActionTransition( previous: .init(state: before.states, reducerState: before._reducerState), @@ -86,7 +84,7 @@ extension Store { ) ) } else { - sideEffect = withLock { reduce(container, action) } + sideEffect = reduce(container, action) } if case .none = sideEffect.kind { @@ -120,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)?