Created
November 1, 2022 11:05
-
-
Save wisecsj/f15afe12c3c7ff1849b4ed52ecb832ab to your computer and use it in GitHub Desktop.
This file contains 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
class Settings { | |
var count:Int=0 | |
} | |
actor Test{ | |
// var count:Int=0 | |
var settings:Settings | |
init(s:Settings){ | |
self.settings = s | |
} | |
} | |
let test = Test(s:Settings()) | |
await withTaskGroup(of: Void.self){group in | |
for i in 1...10000{ | |
print("index:\(i)") | |
group.addTask{ | |
await add() | |
} | |
} | |
} | |
func add() async { | |
await test.settings.count+=1 | |
} | |
print(await test.settings.count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment