Move synchronized method out of JLangJVM
This commit is contained in:
@@ -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"))
|
@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
|
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.
|
* Returns the annotation type of this annotation.
|
||||||
@@ -66,4 +54,4 @@ public fun <T : Annotation> T.annotationType() : Class<out T> =
|
|||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
public inline fun Method.invoke(instance: Any, vararg args: Any?): Any? {
|
public inline fun Method.invoke(instance: Any, vararg args: Any?): Any? {
|
||||||
return invoke(instance, *args)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user