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

Gabriel Feo

06/24/2020, 4:28 PM
Is CoroutineName not supposed to be used in userland? I’m trying to use it log that a certain Job has completed, but it’s always null even though the name was set:
z

Zach Klippenstein (he/him) [MOD]

06/24/2020, 4:34 PM
The name isn't stored in the job, it's stored in the context (which is effectively a map that can contain both a job and a name, as well as a dispatcher, etc)
A job is a CoroutineContext, but it's a context element which means it's a context that only contains itself.
g

Gabriel Feo

06/24/2020, 4:49 PM
Oh, that makes sense. Is there a way to get the Job’s context after launching it?
l

louiscad

06/24/2020, 5:38 PM
No, the Job is just the Job. You can access the
currentCoroutineContext()
though.
5 Views