Skip to content

Commit

Permalink
Fixes issue around mutable capture of 'inout' parameter 'buffer' is n…
Browse files Browse the repository at this point in the history
…ot allowed in concurrently-executing code
  • Loading branch information
mapierce committed Aug 27, 2024
1 parent f1974a5 commit cfcab2a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions SourceryRuntime/Sources/Common/Array+Parallel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public extension Array {
func parallelMap<T>(transform: (Element) -> T) -> [T] {
var result = ContiguousArray<T?>(repeating: nil, count: count)
return result.withUnsafeMutableBufferPointer { buffer in
nonisolated(unsafe) let buffer = buffer
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in
buffer[idx] = transform(self[idx])
}
Expand Down

0 comments on commit cfcab2a

Please sign in to comment.