Created
May 14, 2018 13:54
-
-
Save dmytro-anokhin/f7658fe4da266865f2f376580db807bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CompositeTask: Task { | |
| let tasks: [Task] | |
| init(_ tasks: [Task]) { | |
| self.tasks = tasks | |
| } | |
| func run(_ completion: @escaping (Task) -> Void) { | |
| let group = DispatchGroup() | |
| for task in tasks { | |
| group.enter() | |
| task.run({ task in | |
| group.leave() | |
| }) | |
| } | |
| group.notify(queue: DispatchQueue.main) { | |
| completion(self) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment