Skip to content

Commit

Permalink
remove lock instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 committed Oct 1, 2023
1 parent 152874e commit 5e0ed52
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
3 changes: 1 addition & 2 deletions Sources/SimplexArchitecture/StateContainer.swift
Original file line number Diff line number Diff line change
@@ -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<Target: ActionSendable> {
public var reducerState: Target.Reducer.ReducerState {
Expand Down
7 changes: 0 additions & 7 deletions Sources/SimplexArchitecture/Store/Store+send.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ extension Store {
}
}

@inlinable
func withLock<T>(_ operation: () throws -> T) rethrows -> T {
lock.lock()
defer { lock.unlock() }
return try operation()
}

func makeSend(for container: StateContainer<Reducer.Target>) -> Send<Reducer> {
Send(
sendAction: { [weak self] action in
Expand Down
1 change: 0 additions & 1 deletion Sources/SimplexArchitecture/Store/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public final class Store<Reducer: ReducerProtocol> {
// Buffer to store Actions recurrently invoked through SideEffect in a single Action sent from View
@TestOnly var sentFromEffectActions: [ActionTransition<Reducer>] = []

@usableFromInline let lock = NSRecursiveLock()
@usableFromInline var pullbackAction: ((Reducer.Action) -> Void)?
@usableFromInline var pullbackReducerAction: ((Reducer.ReducerAction) -> Void)?

Expand Down

0 comments on commit 5e0ed52

Please sign in to comment.