1
1
/*
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.
3
3
*/
4
4
5
5
package kotlinx.coroutines.scheduling
@@ -146,7 +146,7 @@ internal class CoroutineScheduler(
146
146
*
147
147
* Note, [newIndex] can be zero for the worker that is being terminated (removed from [workers]).
148
148
*/
149
- internal fun parkedWorkersStackTopUpdate (worker : Worker , oldIndex : Int , newIndex : Int ) {
149
+ fun parkedWorkersStackTopUpdate (worker : Worker , oldIndex : Int , newIndex : Int ) {
150
150
parkedWorkersStack.loop { top ->
151
151
val index = (top and PARKED_INDEX_MASK ).toInt()
152
152
val updVersion = (top + PARKED_VERSION_INC ) and PARKED_VERSION_MASK
@@ -174,7 +174,7 @@ internal class CoroutineScheduler(
174
174
* Returns `true` if worker was added to the stack by this invocation, `false` if it was already
175
175
* registered in the stack.
176
176
*/
177
- internal fun parkedWorkersStackPush (worker : Worker ): Boolean {
177
+ fun parkedWorkersStackPush (worker : Worker ): Boolean {
178
178
if (worker.nextParkedWorker != = NOT_IN_STACK ) return false // already in stack, bail out
179
179
/*
180
180
* 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(
403
403
}
404
404
}
405
405
406
- internal fun createTask (block : Runnable , taskContext : TaskContext ): Task {
406
+ fun createTask (block : Runnable , taskContext : TaskContext ): Task {
407
407
val nanoTime = schedulerTimeSource.nanoTime()
408
408
if (block is Task ) {
409
409
block.submissionTime = nanoTime
@@ -422,7 +422,7 @@ internal class CoroutineScheduler(
422
422
tryUnpark() // Try unpark again in case there was race between permit release and parking
423
423
}
424
424
425
- internal fun signalCpuWork () {
425
+ fun signalCpuWork () {
426
426
if (tryUnpark()) return
427
427
if (tryCreateWorker()) return
428
428
tryUnpark()
@@ -654,7 +654,7 @@ internal class CoroutineScheduler(
654
654
* Releases CPU token if worker has any and changes state to [newState].
655
655
* Returns `true` if CPU permit was returned to the pool
656
656
*/
657
- internal fun tryReleaseCpu (newState : WorkerState ): Boolean {
657
+ fun tryReleaseCpu (newState : WorkerState ): Boolean {
658
658
val previousState = state
659
659
val hadCpu = previousState == WorkerState .CPU_ACQUIRED
660
660
if (hadCpu) releaseCpuPermit()
@@ -774,7 +774,7 @@ internal class CoroutineScheduler(
774
774
* Marsaglia xorshift RNG with period 2^32-1 for work stealing purposes.
775
775
* ThreadLocalRandom cannot be used to support Android and ThreadLocal<Random> is up to 15% slower on Ktor benchmarks
776
776
*/
777
- internal fun nextInt (upperBound : Int ): Int {
777
+ fun nextInt (upperBound : Int ): Int {
778
778
var r = rngState
779
779
r = r xor (r shl 13 )
780
780
r = r xor (r shr 17 )
0 commit comments