in a background thread on iOS?
The client needs to always be owned by the `Worker`'s thread and be accessible to all executions inside that worker 🤔
I basically need state in a
Worker
.
Marc Knaup
06/11/2019, 6:47 PM
I thought about using an
@ThreadLocal
variable for that.
But the documentation isn't very assuring on that:
PLEASE NOTE THAT THIS ANNOTATION MAY GO AWAY IN UPCOMING RELEASES.
o
olonho
06/11/2019, 6:59 PM
Yes, if you indeed want to attach state to given worker - @ThreadLocal is OK. In many other cases - maybe KTor on the main thread or frozen one could be OK.
m
Marc Knaup
06/11/2019, 7:01 PM
Thank you. I'll go with
@ThreadLocal
for now.
HttpClient
cannot be frozen as it has mutable state internally.
Using the main thread negatively affects my performance already in the iOS app and I want to get away from that.
as I suggested in the bug, in case above may make sense to transfer factory, not the created object. However, it could be bug/feature in K/N, to check - force GC run after