Skip to content

Commit

Permalink
update internal boilerplate code.
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzablocki committed Dec 6, 2022
1 parent 75525b0 commit 0781bf1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sourcery CHANGELOG

## Main
## 1.9.1
## New Features
- Adds support for public protocols in AutoMockable template [#1100](https://github.com/krzysztofzablocki/Sourcery/pull/1100)
- Adds support for async and throwing properties to AutoMockable template [#1101](https://github.com/krzysztofzablocki/Sourcery/pull/1101)
Expand Down
57 changes: 0 additions & 57 deletions SourcerySwift/Sources/SourceryRuntime.content.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,63 +149,6 @@ public extension Array {
}
}
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async rethrows -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = count
if n == 0 {
return []
}
return try await withThrowingTaskGroup(of: (Int, T).self, returning: [T].self) { group in
var result = [T?](repeatElement(nil, count: n))
var i = self.startIndex
var submitted = 0
func submitNext() async throws {
if i == self.endIndex { return }
group.addTask { [submitted, i] in
let value = try await transform(self[i])
return (submitted, value)
}
submitted += 1
formIndex(after: &i)
}
// submit first initial tasks
for _ in 0 ..< parallelism {
try await submitNext()
}
// as each task completes, submit a new task until we run out of work
while let (index, taskResult) = try await group.next() {
result[index] = taskResult
try Task.checkCancellation()
try await submitNext()
}
assert(result.count == n)
return Array(result.compactMap { $0 })
}
}
func parallelEach(
parallelism requestedParallelism: Int? = nil,
_ work: @escaping (Element) async throws -> Void
) async rethrows {
_ = try await parallelMap {
try await work($0)
}
}
}
"""),
.init(name: "Array.swift", content:
"""
Expand Down

0 comments on commit 0781bf1

Please sign in to comment.