Last active
February 9, 2023 15:27
-
-
Save rhysm94/3a64bcaa21b88f515b3e58f2726c135a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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