Skip to content
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

Provide an API to close Dispatchers.Default and Dispatchers.IO #2558

Closed
qwwdfsad opened this issue Mar 1, 2021 · 0 comments
Closed

Provide an API to close Dispatchers.Default and Dispatchers.IO #2558

qwwdfsad opened this issue Mar 1, 2021 · 0 comments

Comments

@qwwdfsad
Copy link
Member

@qwwdfsad qwwdfsad commented Mar 1, 2021

In containerized environments (Gradle build scripts, application containers, IDEA plugins), it is important to be able to unload the bundle of classes when the job is done.

Unfortunately, any code that touches our dispatchers (e.g. transitively, or via GlobalScope) cannot be unloaded: few indefinitely parked scheduler threads retain a strong reference to its class loader and cannot be terminated in any public way. For that, we should provide a public API to shutdown our dispatchers, destroy all their threads and make the outer classloader free.

The open question is how to establish a method contract in a way that nicely interacts with the fact that IO and Default are closely tightened and also take into account that depending on the system property, Dispatchers.Default can be backed by ForkJoinPool.commonPool that cannot be shut down (it doesn't suffer from this problem tho, because it's a JDK class that is always loaded by a bootstrap classloader).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant