Skip to content

Commit 6854be1

Browse files
authored
Make internal functions public in already internal CoroutineScheduler in order to get prettier stacktraces without "$kotlinx_coroutines_core" in function names (#2487)
1 parent 7548b83 commit 6854be1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kotlinx-coroutines-core/jvm/src/scheduling/CoroutineScheduler.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.coroutines.scheduling
@@ -146,7 +146,7 @@ internal class CoroutineScheduler(
146146
*
147147
* Note, [newIndex] can be zero for the worker that is being terminated (removed from [workers]).
148148
*/
149-
internal fun parkedWorkersStackTopUpdate(worker: Worker, oldIndex: Int, newIndex: Int) {
149+
fun parkedWorkersStackTopUpdate(worker: Worker, oldIndex: Int, newIndex: Int) {
150150
parkedWorkersStack.loop { top ->
151151
val index = (top and PARKED_INDEX_MASK).toInt()
152152
val updVersion = (top + PARKED_VERSION_INC) and PARKED_VERSION_MASK
@@ -174,7 +174,7 @@ internal class CoroutineScheduler(
174174
* Returns `true` if worker was added to the stack by this invocation, `false` if it was already
175175
* registered in the stack.
176176
*/
177-
internal fun parkedWorkersStackPush(worker: Worker): Boolean {
177+
fun parkedWorkersStackPush(worker: Worker): Boolean {
178178
if (worker.nextParkedWorker !== NOT_IN_STACK) return false // already in stack, bail out
179179
/*
180180
* The below loop can be entered only if this worker was not in the stack and, since no other thread
@@ -403,7 +403,7 @@ internal class CoroutineScheduler(
403403
}
404404
}
405405

406-
internal fun createTask(block: Runnable, taskContext: TaskContext): Task {
406+
fun createTask(block: Runnable, taskContext: TaskContext): Task {
407407
val nanoTime = schedulerTimeSource.nanoTime()
408408
if (block is Task) {
409409
block.submissionTime = nanoTime
@@ -422,7 +422,7 @@ internal class CoroutineScheduler(
422422
tryUnpark() // Try unpark again in case there was race between permit release and parking
423423
}
424424

425-
internal fun signalCpuWork() {
425+
fun signalCpuWork() {
426426
if (tryUnpark()) return
427427
if (tryCreateWorker()) return
428428
tryUnpark()
@@ -654,7 +654,7 @@ internal class CoroutineScheduler(
654654
* Releases CPU token if worker has any and changes state to [newState].
655655
* Returns `true` if CPU permit was returned to the pool
656656
*/
657-
internal fun tryReleaseCpu(newState: WorkerState): Boolean {
657+
fun tryReleaseCpu(newState: WorkerState): Boolean {
658658
val previousState = state
659659
val hadCpu = previousState == WorkerState.CPU_ACQUIRED
660660
if (hadCpu) releaseCpuPermit()
@@ -774,7 +774,7 @@ internal class CoroutineScheduler(
774774
* Marsaglia xorshift RNG with period 2^32-1 for work stealing purposes.
775775
* ThreadLocalRandom cannot be used to support Android and ThreadLocal<Random> is up to 15% slower on Ktor benchmarks
776776
*/
777-
internal fun nextInt(upperBound: Int): Int {
777+
fun nextInt(upperBound: Int): Int {
778778
var r = rngState
779779
r = r xor (r shl 13)
780780
r = r xor (r shr 17)

0 commit comments

Comments
 (0)