1 /* 2 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.coroutines.exceptions 6 7 import kotlin.random.* 8 randomWaitnull9actual fun randomWait() { 10 val n = Random.nextInt(1000) 11 if (n < 500) return // no wait 50% of time 12 repeat(n) { 13 BlackHole.sink *= 3 14 } 15 if (n > 900) Thread.yield() 16 } 17 18 private object BlackHole { 19 @Volatile 20 var sink = 1 21 } 22 23 @Suppress("ACTUAL_WITHOUT_EXPECT") 24 internal actual typealias SuppressSupportingThrowable = Throwable 25 26 @Suppress("EXTENSION_SHADOWED_BY_MEMBER") printStackTracenull27actual fun Throwable.printStackTrace() = printStackTrace() 28 29 actual fun currentThreadName(): String = Thread.currentThread().name 30