implement infinite worlds with threaded chunk generation

This commit is contained in:
Alex Zenla
2024-09-03 09:18:35 -04:00
parent 6f985ce1c9
commit 5e40e12c8b
7 changed files with 133 additions and 18 deletions

View File

@ -62,6 +62,14 @@ public class ConcurrentDictionary<V: Hashable, T>: Collection {
}
}
public func take() -> Dictionary<V, T> {
self.locked {
let current = self.inner
self.inner = [:]
return current
}
}
fileprivate func locked<X>(_ perform: () -> X) -> X {
self.lock.lock()
defer {