Skip to content

Instantly share code, notes, and snippets.

@lacyrhoades
Last active July 25, 2017 18:04
Show Gist options
  • Save lacyrhoades/c45c19ee103ee2d6c802cabcfa288956 to your computer and use it in GitHub Desktop.
Save lacyrhoades/c45c19ee103ee2d6c802cabcfa288956 to your computer and use it in GitHub Desktop.
func doTheThing() {
// First let's at least try to fix up each thing
// Has to be one-at-a-time
let waitGroup = DispatchGroup()
for missingID in self.missingIDs {
waitGroup.enter()
self.utility.tryToFixStuff(forItemID: missingID) {
waitGroup.leave()
}
waitGroup.wait() // this optionally takes a timeout param
}
// Go on doing the rest of the thing
// ...
}
@lacyrhoades
Copy link
Author

lacyrhoades commented Jul 25, 2017

I'm always worried like "What if tryToFixStuff never calls me back!?" – Not sure if that's rational.

@pzearfoss-capone
Copy link

What are the odds that it fails? If it's a network thing there should be a time out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment