https://kotlinlang.org logo
#coroutines
Title
# coroutines
g

groostav

08/09/2018, 9:41 AM
So the first thing that might help here is using the
Unconfined
dispatcher in your
map
function, I think this will get your outer deferred running on the inner deferred's thread, which might make this a bit more straight forward to debug
n

nayanjyoti

08/10/2018, 6:14 AM
So yes, If i use the Unconfined dispatcher it works. I also changed the dispatcher to be a threadpool with 1 thread. that also works. I believe the cpu cache theory is the thing here. Since the map isn’t a true function (returning the same instance), i believe if somehow the other thread got hold of that instance the lookups are not done to heap, instead from the cpu cache, in which case it will see the stale value, as the field isn’t volatile. @groostav
5 Views