Last active
July 31, 2024 16:01
-
-
Save mattmassicotte/ea20e3ea3cb7dd95514253d806cd01ec 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 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