-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Shouldn't join resume after onCompletion? #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We have a feature for that — atomic start mode. |
Thanks @elizarov. I can, indeed make sure that my example always execute But I don't really care if What I'm saying is that despite that the goal of I'd like to quote yourself (in #279) about the solution of
|
And still fun foo() {
Thread.sleep(1000)
println("alright this have been executed")
}
fun main(args: Array<String>) {
val job = Job()
job.cancel()
GlobalScope.launch(job, start = CoroutineStart.ATOMIC, onCompletion = { foo() }) { println("do stuff") }
runBlocking {
println("before join")
job.cancelAndJoin()
println("after join")
}
} But the result is:
And I'd like to get:
|
We've deprecated |
Yes indeed.
Ok. thanks. Before I close this issue, may I ask what will be the preferred solution to #279? Shall we use |
For now, Btw, if you are only interested in exceptions, you can install |
Ops. We need to promote |
Hello,
please consider the following code:
foo()
is not invoked at all, because the job is cancelled before being scheduled.So what are my options, if I want to make sure
foo()
is always executed?One may try to use
onCompletion
like this:But it doesn't help, because
join
doesn't seem to care ifonCompletion
have been executed or not.And here comes my question: Shouldn't
join
resume only after the executiononCompletion
?The text was updated successfully, but these errors were encountered: