Skip to content

Instantly share code, notes, and snippets.

@regularberry
Last active May 30, 2018 20:26
Show Gist options
  • Save regularberry/65c99ba268655282cccfc5f35a745840 to your computer and use it in GitHub Desktop.
Save regularberry/65c99ba268655282cccfc5f35a745840 to your computer and use it in GitHub Desktop.
func testMutableClass() {
let group = DispatchGroup()
let obj = MutableClass()
for _ in 0...1000 {
group.enter()
DispatchQueue.global().async {
let sleepVal = arc4random() % 1000
usleep(sleepVal)
obj.update(newVal: 42)
group.leave()
}
}
let result = group.wait(timeout: DispatchTime.now() + 5)
XCTAssert(result == .success)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment