Removed reflection requirement
This commit is contained in:
parent
75ae20580c
commit
535f33b23a
@ -32,18 +32,10 @@ import java.io.StringWriter
|
|||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.coroutineContext
|
import kotlin.coroutines.coroutineContext
|
||||||
|
|
||||||
inline fun <reified T> T.logger(name: String): KLogger {
|
inline fun <reified T> T.logger(name: String = T::class.java.simpleName): KLogger {
|
||||||
return KotlinLogging.logger(name)
|
return KotlinLogging.logger(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T> T.logger(): KLogger {
|
|
||||||
if (T::class.isCompanion) {
|
|
||||||
return KotlinLogging.logger(T::class.java.enclosingClass.simpleName)
|
|
||||||
}
|
|
||||||
return KotlinLogging.logger(T::class.java.simpleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun Exception.stackTraceToString(): String {
|
fun Exception.stackTraceToString(): String {
|
||||||
val exceptionWriter = StringWriter()
|
val exceptionWriter = StringWriter()
|
||||||
printStackTrace(PrintWriter(exceptionWriter))
|
printStackTrace(PrintWriter(exceptionWriter))
|
||||||
@ -69,12 +61,19 @@ inline fun ignoreExceptions(vararg blocks: () -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun async(dispatcher: CoroutineDispatcher = Dispatchers.IO, action: suspend CoroutineScope.() -> Unit): Job {
|
fun async(dispatcher: CoroutineDispatcher, action: suspend CoroutineScope.() -> Unit): Job {
|
||||||
return GlobalScope.launch(dispatcher) {
|
return GlobalScope.launch(dispatcher) {
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun asyncIO(action: suspend CoroutineScope.() -> Unit): Job {
|
||||||
|
return GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun <T> Mutex.withReentrantLock(block: suspend () -> T): T {
|
suspend fun <T> Mutex.withReentrantLock(block: suspend () -> T): T {
|
||||||
val key = ReentrantMutexContextKey(this)
|
val key = ReentrantMutexContextKey(this)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user