-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Internal API to retreive a single CPU-bound task from Dispatchers.Default #3439
Comments
FTR another solution was considered: let |
There is still a problem with thread-locals. We can manage our own thread-locals and reset them before running the
|
I would love to know how we can implement non-transparent AFAIR there is no API in Java to clean up and later recover all thread locals. |
We've recently had a starved thread situation after incorrect migration to coroutines in IJ (https://youtrack.jetbrains.com/issue/IDEA-302358), but it was using
We are interested in |
Another possible approach is to provide a single-function API with the semantics like this:
|
Attaching unfinished attempt to implement this as per request in a private conversation |
IntelliJ IDEA platform has the following core API:
Such API is composable in a way that it is possible to call
decompose
recursively from within subtasks.It may be tempting to rewrite it with coroutines in a following manner:
The problem is -- this code is prone to both starvation and deadlocks -- each call to decompose from
Dispatchers.Default
occupies at least one thread in the backing executor forjoinBlocking()
, meaning that eventually, such code may deadlock.It is not the case for the FJP-based solution, because
.join
on any FJP task not only awaits for the task to complete but also helps to execute subtasks if the joining thread is part of the target's FJP.It doesn't seem that we can provide a full-blown FJP-like API out-of-the-box, but as the first steps we can provide an internal TBD API
getSingleDispatchersDefaultTaskOrNull
. With such API, it is possible to emulatedecompose
API and, after initial evaluation by the IDEA team, we may want to promote it to@Delicate
API as one more way to bridge blocking calls with coroutine dispatchers.The text was updated successfully, but these errors were encountered: