Move synchronized method out of JLangJVM

This commit is contained in:
Ilya Gorbunov
2015-09-22 17:20:09 +03:00
parent 27ab643d3f
commit 13132e7483
2 changed files with 18 additions and 13 deletions
+1 -13
View File
@@ -41,18 +41,6 @@ public val <T: Any> T.javaClass : Class<T>
@Deprecated("Use the class reference and .java extension property instead: MyClass::class.java", ReplaceWith("T::class.java"))
public fun <reified T: Any> javaClass(): Class<T> = T::class.java
/**
* Executes the given function [block] while holding the monitor of the given object [lock].
*/
public inline fun <R> synchronized(lock: Any, block: () -> R): R {
monitorEnter(lock)
try {
return block()
}
finally {
monitorExit(lock)
}
}
/**
* Returns the annotation type of this annotation.
@@ -66,4 +54,4 @@ public fun <T : Annotation> T.annotationType() : Class<out T> =
@Suppress("NOTHING_TO_INLINE")
public inline fun Method.invoke(instance: Any, vararg args: Any?): Any? {
return invoke(instance, *args)
}
}
@@ -0,0 +1,17 @@
@file:JvmVersion
package kotlin
import kotlin.jvm.internal.unsafe.*
/**
* Executes the given function [block] while holding the monitor of the given object [lock].
*/
public inline fun <R> synchronized(lock: Any, block: () -> R): R {
monitorEnter(lock)
try {
return block()
}
finally {
monitorExit(lock)
}
}