Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created January 28, 2024 07:56
Show Gist options
  • Save laevandus/766c4fd7093f92a246667663ad9b93c8 to your computer and use it in GitHub Desktop.
Save laevandus/766c4fd7093f92a246667663ad9b93c8 to your computer and use it in GitHub Desktop.
func testThreadSafety() throws {
let iterations = 100
let storage = Storage()
DispatchQueue.concurrentPerform(iterations: iterations) { index in
storage.store(Data(), forIdentifier: "\(index)")
}
XCTAssertEqual(storage.numberOfItems, iterations)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment