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

basher

05/02/2019, 12:30 AM
If you create a class that implements CoroutineScope and keeps a local property to a
Job
, is the job cancelled if that object and the job are collected?
s

streetsofboston

05/02/2019, 1:28 AM
If you mean garbage collected: No, I don't think so. A Job is not cancelled when it's finalized. (and this wouldn't have worked on multi-platform Kotlin either, since there may not be any garbage collection)
b

basher

05/02/2019, 1:48 AM
Yes garbage collected. Thanks!
e

elizarov

05/02/2019, 3:31 AM
finalizers are evil. You should not be using them even on JVM
b

basher

05/02/2019, 3:39 AM
👍 generally agree. Just trying to understand cleanup responsibilities when you have your own CoroutineScope class that owns a Job
k

kevin.cianfarini

05/03/2019, 1:17 AM
@elizarov just for my own curiosity, can you explain why finalizers are evil?
nevermind, did some reading. They are evil.
2 Views