Skip to content

Instantly share code, notes, and snippets.

@mattmassicotte
Last active July 31, 2024 16:01
Show Gist options
  • Save mattmassicotte/ea20e3ea3cb7dd95514253d806cd01ec to your computer and use it in GitHub Desktop.
Save mattmassicotte/ea20e3ea3cb7dd95514253d806cd01ec to your computer and use it in GitHub Desktop.
class NonSendable {
var value = 1
}
class NonIsolated {
private var mutableState = NonSendable()
func aFunc() async {
mutableState.value += 1
}
}
class UseNonIsolated {
let value = NonIsolated()
// this is non-isolated
func useAFunc() async {
// so this does not change isolation and is ok
await value.aFunc()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment