Skip to content

Instantly share code, notes, and snippets.

@rhysm94
Last active February 9, 2023 15:27
Show Gist options
  • Save rhysm94/3a64bcaa21b88f515b3e58f2726c135a to your computer and use it in GitHub Desktop.
Save rhysm94/3a64bcaa21b88f515b3e58f2726c135a to your computer and use it in GitHub Desktop.
import Foundation
class CounterSortaActor {
let queue = DispatchQueue(label: "CounterQueue")
private var _count = 0
var count: Int {
get {
queue.sync { _count }
}
set {
queue.sync {
_count += 1
}
}
}
}
actor CounterActor {
var count = 0
func increment() {
count += 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment