[RIDER] Expand documentation for cancelCurrentInputEventProcessingAndRun method

GitOrigin-RevId: a6572cf2d1fc56b01fbe9765f241ca3364fa9d8e
This commit is contained in:
Nikita.Lyubimov
2024-07-12 10:46:10 +02:00
committed by intellij-monorepo-bot
parent 3c5a960ecd
commit 60ab8bb505

View File

@@ -981,7 +981,18 @@ object Utils {
private val cancellationDispatcher = Dispatchers.IO.limitedParallelism(1)
private var ourCurrentInputEventProcessingJobFlow = MutableStateFlow<Job?>(null)
// DO NOT USE. RIDER ONLY!
/**
* DO NOT USE. RIDER ONLY!
* Cancels the current input event processing and runs the provided block.
*
* This method ensures that any ongoing input event processing is canceled before running the block.
* Using to prevent deadlock when EDT is blocked by runWithInputEventEdtDispatcher and important sync call from
* the backend main thread is requiring to run something on the EDT
*
* @param block The suspending function to execute after cancelling the current input event processing.
* @return The result of the provided block function.
*/
@DelicateCoroutinesApi
suspend fun <T> cancelCurrentInputEventProcessingAndRun(block: suspend () -> T): T = coroutineScope {
val cancelJob = launch(cancellationDispatcher) {
ourCurrentInputEventProcessingJobFlow.collectLatest {