Skip to content

Commit

Permalink
Update RefdsTask.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Aug 22, 2024
1 parent ecd801e commit 96b354f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/RefdsShared/Task/RefdsTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import Foundation

public protocol RefdsTaskProtocol {
typealias ExecuteItem = () -> Void
typealias ControlExecuteItem = (DispatchGroup) -> Void

func execute(items: [ExecuteItem])
func execute(items: [ControlExecuteItem])
}

public final class RefdsTask: RefdsTaskProtocol {
Expand Down Expand Up @@ -33,4 +36,14 @@ public final class RefdsTask: RefdsTaskProtocol {
}
group.wait()
}

public func execute(items: [ControlExecuteItem]) {
items.forEach { item in
group.enter()
queue.async {
item(self.group)
}
}
group.wait()
}
}

0 comments on commit 96b354f

Please sign in to comment.