Skip to content

Instantly share code, notes, and snippets.

@dduan

dduan/Repro.swift

Created Oct 12, 2018
Embed
What would you like to do?
import Dispatch
class Runner {
var observers = [String: () -> Void]()
let queue = DispatchQueue(label: "foo-queue")
func run() {
let observers = self.observers
for _ in 0..<20000 {
let c: () -> Void = { [weak self] in
self?.queue.async { [weak self] in
self?.observers.removeValue(forKey: "")
}
}
self.observers[""] = c
c()
for (_, observer) in self.observers {
DispatchQueue.main.async {
observer()
}
}
}
}
}
Runner().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.