adjpd
02/13/2022, 3:45 AMclass
that takes a suspend
function, passedFn
, as a parameter. And the class has a suspend
method, fn()
. When fn()
calls passedFn()
I receive this error on iOS illegal attempt to access non-shared Something.$fnCOROUTINE$0@2d9f788 from other thread.
I'm vaguely aware it has something to do with freezing objects across threads. Could anyone enlighten me further? What would I need to do in order to get this to work?adjpd
02/13/2022, 3:46 AMclass Something(
val passedFn: suspend () -> Unit,
) {
suspend fun fn(): Boolean {
passedFn() // crash here
return true
}
}
adjpd
02/13/2022, 3:46 AMclass AFunction : KotlinSuspendFunction0 {
func invoke() async throws -> Any? {
return nil
}
}
Something(myfn: AFunction()).fn() { v, e in
print("hello \(v)")
}
michaelv
02/13/2022, 5:17 AMmichaelv
02/13/2022, 5:18 AMadjpd
02/13/2022, 12:10 PMkotlin.native.binary.memoryModel=experimental
is my gradle properties and now it's all working. Thanks you enormously