Skip to content

Commit c571546

Browse files
authored
Use a lock consistently in the ExecutionContext class (apple#619)
The changes in this PR improve the consistency of using a lock in the `ExecutionContext` class.
1 parent 449f1d2 commit c571546

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Sources/NativeBuilder/ContainerBuildExecutor/ExecutionContext.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,19 @@ public final class ExecutionContext: @unchecked Sendable {
175175

176176
/// Create a child context for a nested execution.
177177
public func childContext(for stage: BuildStage) -> ExecutionContext {
178-
lock.withLock {
179-
ExecutionContext(
180-
stage: stage,
181-
graph: graph,
182-
platform: platform,
183-
reporter: reporter,
184-
snapshotter: snapshotter,
185-
baseEnvironment: Environment(_environment.variables),
186-
baseConfig: _imageConfig
187-
)
178+
let (environmentVars, imageConfig) = lock.withLock {
179+
(_environment.variables, _imageConfig)
188180
}
181+
182+
return ExecutionContext(
183+
stage: stage,
184+
graph: graph,
185+
platform: platform,
186+
reporter: reporter,
187+
snapshotter: snapshotter,
188+
baseEnvironment: Environment(environmentVars),
189+
baseConfig: imageConfig
190+
)
189191
}
190192

191193
// MARK: - Snapshotter Integration

0 commit comments

Comments
 (0)