Erik
02/26/2021, 6:47 PMobject
with private construct-once properties (e.g. private val x = SomeConstructor()
) and public suspend
functions that access these properties. The suspending funs all use withContext(myContext) {}
to ensure they access the properties from the correct thread. How can I ensure that the properties are instantiated on that same thread? Would it be enough to use private val x by lazy { SomeConstructor() }
as long as x
is only accessed from within withContext(myContext)
? Will that guarantee that x
is constructed on the thread(s) backing myContext
?myungpyo.shim
02/27/2021, 6:53 AMErik
02/27/2021, 7:06 AM