Merge pull request #5600 from continuedev/pe/jb-limit-thread-parallelism

feat(JB): limit to 4 threads in `handleMessage`
This commit is contained in:
Nate Sesti 2025-05-09 16:59:23 -07:00 • committed by GitHub
commit 69197296e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,6 +40,14 @@ class IdeProtocolClient(
) : DumbAware {
private val ide: IDE = IntelliJIDE(project, continuePluginService)
/**
* Create a dispatcher with limited parallelism to prevent UI freezing.
* Note that there are 64 total threads available to the IDE.
*
* See this thread for details: https://github.com/continuedev/continue/issues/4098#issuecomment-2854865310
*/
private val limitedDispatcher = Dispatchers.IO.limitedParallelism(4)
init {
// Setup config.json / config.ts save listeners
VirtualFileManager.getInstance().addAsyncFileListener(
@ -52,7 +60,7 @@ class IdeProtocolClient(
}
fun handleMessage(msg: String, respond: (Any?) -> Unit) {
coroutineScope.launch(Dispatchers.IO) {
coroutineScope.launch(limitedDispatcher) {
val message = Gson().fromJson(msg, Message::class.java)
val messageType = message.messageType
val dataElement = message.data
@ -685,4 +693,4 @@ class IdeProtocolClient(
fun deleteAtIndex(index: Int) {
continuePluginService.sendToWebview("deleteAtIndex", DeleteAtIndex(index), uuid())
}
}
}