-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathConcurrent.kt
22 lines (16 loc) · 931 Bytes
/
Concurrent.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package kotlinx.coroutines.internal
import java.util.*
import kotlin.concurrent.withLock as withLockJvm
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias ReentrantLock = java.util.concurrent.locks.ReentrantLock
internal actual inline fun <T> ReentrantLock.withLock(action: () -> T) = this.withLockJvm(action)
@Suppress("ACTUAL_WITHOUT_EXPECT") // Visibility
internal actual typealias WorkaroundAtomicReference<T> = java.util.concurrent.atomic.AtomicReference<T>
// BenignDataRace is OptionalExpectation and doesn't have to be here
// but then IC breaks. See KT-66317
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FIELD)
internal actual annotation class BenignDataRace()
@Suppress("NOTHING_TO_INLINE") // So that R8 can completely remove ConcurrentKt class
internal actual inline fun <E> identitySet(expectedSize: Int): MutableSet<E> =
Collections.newSetFromMap(IdentityHashMap(expectedSize))