jvmTest.linearizability.MutexLCStressTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-coroutines-core-metadata Show documentation
Show all versions of kotlinx-coroutines-core-metadata Show documentation
Coroutines support libraries for Kotlin
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@file:Suppress("unused")
package kotlinx.coroutines.linearizability
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import org.jetbrains.kotlinx.lincheck.annotations.Operation
import org.jetbrains.kotlinx.lincheck.verifier.*
import org.junit.*
class MutexLCStressTest : VerifierState() {
private val mutex = Mutex()
@Operation
fun tryLock() = mutex.tryLock()
@Operation
suspend fun lock() = mutex.lock()
@Operation(handleExceptionsAsResult = [IllegalStateException::class])
fun unlock() = mutex.unlock()
@Test
fun test() = LCStressOptionsDefault()
.actorsBefore(0)
.check(this::class)
override fun extractState() = mutex.isLocked
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy