-
Notifications
You must be signed in to change notification settings - Fork 1.9k
WeakJob #2626
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
Currently there is way to get the same functionality (as I understand): val scope = CoroutineScope(Dispatchers.Default)
val subScope = CoroutineScope(scope.coroutineContext)
scope.coroutineContext.job.invokeOnCompletion { subScope.cancel() }
subScope.launch {
while (isActive) {
println("still working")
}
}
scope.launch {
delay(5100L)
println("that will be last one")
} |
The name |
I have suggested this name exactly because of weak this scope is not direct child and should not be counted as subscope for its parent |
I wrote something similar here: #1065 |
I have a feature request about
WeakJob
s. Currently in my practice there are tasks (Job
) which are not important in context ofCoroutinesScope
and can be (sometimesmust
be) cancelled when there are no any strongJob
(commonJob
) left in thisCoroutineScope
. As I remember, currently when we are callinglaunch
/async
methods onCoroutineScope
we will get newJob
and thisJob
will prohibitCoroutineScope
to be completed untilJob
will not be completed too.Example of syntax
It is expected that the code above will print:
The text was updated successfully, but these errors were encountered: