Files
kotlin-fork/compiler/testData/codegen/boxWithStdlib/inline/kt6895.kt
T
2016-03-09 10:25:38 +03:00

25 lines
487 B
Kotlin
Vendored

// WITH_RUNTIME
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.write
class UpdateableThing {
private val lock = ReentrantReadWriteLock()
private var updateCount = 0
fun <T> performUpdates(block: () -> T): T {
lock.write {
++updateCount
val result = block()
--updateCount
return result
}
}
}
fun box(): String {
return UpdateableThing().performUpdates { "OK" }
}