Skip to content

Commit 051ca5d

Browse files
committed
expose runBlockingWithParallelismCompensation in IntellijCoroutines
1 parent 9bacb83 commit 051ca5d

File tree

1 file changed

+11
-0
lines changed
  • kotlinx-coroutines-core/jvm/src/internal/intellij

1 file changed

+11
-0
lines changed

kotlinx-coroutines-core/jvm/src/internal/intellij/intellij.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
package kotlinx.coroutines.internal.intellij
55

66
import kotlinx.coroutines.CoroutineDispatcher
7+
import kotlinx.coroutines.CoroutineScope
78
import kotlinx.coroutines.InternalCoroutinesApi
89
import kotlinx.coroutines.internal.softLimitedParallelism as softLimitedParallelismImpl
910
import kotlinx.coroutines.internal.SoftLimitedDispatcher
11+
import kotlinx.coroutines.runBlockingWithParallelismCompensation as runBlockingWithParallelismCompensationImpl
1012
import kotlinx.coroutines.Dispatchers
1113
import kotlin.coroutines.*
14+
import kotlin.jvm.Throws
1215

1316
internal val currentContextThreadLocal : ThreadLocal<CoroutineContext?> = ThreadLocal.withInitial { null }
1417

@@ -29,6 +32,14 @@ public object IntellijCoroutines {
2932
return currentContextThreadLocal.get()
3033
}
3134

35+
/**
36+
* An analogue of [runBlocking][kotlinx.coroutines.runBlocking] that [compensates parallelism][kotlinx.coroutines.scheduling.withCompensatedParallelism]
37+
* while the coroutine is not complete and the associated event loop has no immediate work available.
38+
*/
39+
@Throws(InterruptedException::class)
40+
public fun <T> runBlockingWithParallelismCompensation(context: CoroutineContext, block: suspend CoroutineScope.() -> T): T =
41+
runBlockingWithParallelismCompensationImpl(context, block)
42+
3243
/**
3344
* Constructs a [SoftLimitedDispatcher] from the specified [CoroutineDispatcher].
3445
* [SoftLimitedDispatcher] behaves as [LimitedDispatcher][kotlinx.coroutines.internal.LimitedDispatcher] but allows

0 commit comments

Comments
 (0)