mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-25 17:20:24 +00:00
fix of #541
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package dev.inmo.micro_utils.coroutines
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
@@ -16,6 +17,45 @@ inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend
|
|||||||
* Use [subscribe], but all [block]s will be called inside of [safely] function.
|
* Use [subscribe], but all [block]s will be called inside of [safely] function.
|
||||||
* Use [onException] to set up your reaction for [Throwable]s
|
* Use [onException] to set up your reaction for [Throwable]s
|
||||||
*/
|
*/
|
||||||
|
inline fun <T> Flow<T>.subscribeLogging(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
noinline errorMessageBuilder: T.(Throwable) -> Any = { "Something web wrong" },
|
||||||
|
logger: KSLog = KSLog,
|
||||||
|
noinline block: suspend (T) -> Unit
|
||||||
|
) = subscribe(scope) {
|
||||||
|
it.runCatchingLogging(
|
||||||
|
errorMessageBuilder,
|
||||||
|
logger
|
||||||
|
) {
|
||||||
|
block(it)
|
||||||
|
}.getOrThrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use [subscribeSafelyWithoutExceptions], but all exceptions will be passed to [defaultSafelyExceptionHandler]
|
||||||
|
*/
|
||||||
|
inline fun <T> Flow<T>.subscribeLoggingDropExceptions(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
noinline errorMessageBuilder: T.(Throwable) -> Any = { "Something web wrong" },
|
||||||
|
logger: KSLog = KSLog,
|
||||||
|
noinline block: suspend (T) -> Unit
|
||||||
|
) = subscribe(scope) {
|
||||||
|
it.runCatchingLogging(
|
||||||
|
errorMessageBuilder,
|
||||||
|
logger
|
||||||
|
) {
|
||||||
|
block(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use [subscribe], but all [block]s will be called inside of [safely] function.
|
||||||
|
* Use [onException] to set up your reaction for [Throwable]s
|
||||||
|
*/
|
||||||
|
@Deprecated(
|
||||||
|
"Will be removed soon due to replacement by subscribeLogging",
|
||||||
|
ReplaceWith("this.subscribeLogging(scope = scope, block = block)")
|
||||||
|
)
|
||||||
inline fun <T> Flow<T>.subscribeSafely(
|
inline fun <T> Flow<T>.subscribeSafely(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||||
@@ -29,6 +69,10 @@ inline fun <T> Flow<T>.subscribeSafely(
|
|||||||
/**
|
/**
|
||||||
* Use [subscribeSafelyWithoutExceptions], but all exceptions will be passed to [defaultSafelyExceptionHandler]
|
* Use [subscribeSafelyWithoutExceptions], but all exceptions will be passed to [defaultSafelyExceptionHandler]
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(
|
||||||
|
"Will be removed soon due to replacement by subscribeLoggingDropExceptions",
|
||||||
|
ReplaceWith("this.subscribeLoggingDropExceptions(scope = scope, block = block)")
|
||||||
|
)
|
||||||
inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(
|
inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,
|
noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,
|
||||||
@@ -42,6 +86,10 @@ inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(
|
|||||||
/**
|
/**
|
||||||
* Use [subscribeSafelyWithoutExceptions], but all exceptions inside of [safely] will be skipped
|
* Use [subscribeSafelyWithoutExceptions], but all exceptions inside of [safely] will be skipped
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(
|
||||||
|
"Will be removed soon due to replacement by subscribeLoggingDropExceptions",
|
||||||
|
ReplaceWith("this.subscribeLoggingDropExceptions(scope = scope, block = block)")
|
||||||
|
)
|
||||||
inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(
|
inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
noinline block: suspend (T) -> Unit
|
noinline block: suspend (T) -> Unit
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ private class SubscribeAsyncReceiver<T>(
|
|||||||
get() = dataChannel
|
get() = dataChannel
|
||||||
|
|
||||||
init {
|
init {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
for (data in dataChannel) {
|
for (data in dataChannel) {
|
||||||
output(data)
|
output(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,49 +7,49 @@ import kotlin.coroutines.CoroutineContext
|
|||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
fun CoroutineScope.launchLogging(
|
fun CoroutineScope.launchLogging(
|
||||||
errorMessageBuilder: () -> Any = { "Something web wrong" },
|
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" },
|
||||||
logger: KSLog = KSLog,
|
logger: KSLog = KSLog,
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> Unit
|
block: suspend CoroutineScope.() -> Unit
|
||||||
) = launch(context, start) {
|
) = launch(context, start) {
|
||||||
runCatching { block() }.onFailure {
|
runCatching { block() }.onFailure {
|
||||||
logger.e(it, errorMessageBuilder)
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
}.getOrThrow()
|
}.getOrThrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CoroutineScope.launchLoggingDropExceptions(
|
fun CoroutineScope.launchLoggingDropExceptions(
|
||||||
errorMessageBuilder: () -> Any = { "Something web wrong" },
|
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" },
|
||||||
logger: KSLog = KSLog,
|
logger: KSLog = KSLog,
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> Unit
|
block: suspend CoroutineScope.() -> Unit
|
||||||
) = launch(context, start) {
|
) = launch(context, start) {
|
||||||
runCatching { block() }.onFailure {
|
runCatching { block() }.onFailure {
|
||||||
logger.e(it, errorMessageBuilder)
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
} // just dropping exception
|
} // just dropping exception
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> CoroutineScope.asyncLogging(
|
fun <T> CoroutineScope.asyncLogging(
|
||||||
errorMessageBuilder: () -> Any = { "Something web wrong" },
|
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" },
|
||||||
logger: KSLog = KSLog,
|
logger: KSLog = KSLog,
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> T
|
block: suspend CoroutineScope.() -> T
|
||||||
) = async(context, start) {
|
) = async(context, start) {
|
||||||
runCatching { block() }.onFailure {
|
runCatching { block() }.onFailure {
|
||||||
logger.e(it, errorMessageBuilder)
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
}.getOrThrow()
|
}.getOrThrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> CoroutineScope.asyncLoggingDropExceptions(
|
fun <T> CoroutineScope.asyncLoggingDropExceptions(
|
||||||
errorMessageBuilder: () -> Any = { "Something web wrong" },
|
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" },
|
||||||
logger: KSLog = KSLog,
|
logger: KSLog = KSLog,
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> T
|
block: suspend CoroutineScope.() -> T
|
||||||
) = async(context, start) {
|
) = async(context, start) {
|
||||||
runCatching { block() }.onFailure {
|
runCatching { block() }.onFailure {
|
||||||
logger.e(it, errorMessageBuilder)
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import kotlinx.coroutines.*
|
|||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This method will be removed soon. Use launchLogging instead",
|
||||||
|
ReplaceWith("this.launchLogging(context = context, start = start, block = block)")
|
||||||
|
)
|
||||||
fun CoroutineScope.launchSafely(
|
fun CoroutineScope.launchSafely(
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
@@ -15,6 +19,10 @@ fun CoroutineScope.launchSafely(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This method will be removed soon. Use launchLoggingDropExceptions instead",
|
||||||
|
ReplaceWith("this.launchLoggingDropExceptions(context = context, start = start, block = block)")
|
||||||
|
)
|
||||||
fun CoroutineScope.launchSafelyWithoutExceptions(
|
fun CoroutineScope.launchSafelyWithoutExceptions(
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
@@ -26,6 +34,10 @@ fun CoroutineScope.launchSafelyWithoutExceptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This method will be removed soon. Use asyncLogging instead",
|
||||||
|
ReplaceWith("this.asyncLogging(context = context, start = start, block = block)")
|
||||||
|
)
|
||||||
fun <T> CoroutineScope.asyncSafely(
|
fun <T> CoroutineScope.asyncSafely(
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
@@ -37,6 +49,10 @@ fun <T> CoroutineScope.asyncSafely(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This method will be removed soon. Use asyncLoggingDropExceptions instead",
|
||||||
|
ReplaceWith("this.asyncLoggingDropExceptions(context = context, start = start, block = block)")
|
||||||
|
)
|
||||||
fun <T> CoroutineScope.asyncSafelyWithoutExceptions(
|
fun <T> CoroutineScope.asyncSafelyWithoutExceptions(
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
|
import dev.inmo.kslog.common.e
|
||||||
|
|
||||||
|
inline fun <T, R> R.runCatchingLogging(
|
||||||
|
noinline errorMessageBuilder: R.(Throwable) -> Any = { "Something web wrong" },
|
||||||
|
logger: KSLog = KSLog,
|
||||||
|
block: R.() -> T
|
||||||
|
) = runCatching(block).onFailure {
|
||||||
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
|
}
|
||||||
@@ -128,8 +128,10 @@ open class DefaultStatesMachine <T: State>(
|
|||||||
*/
|
*/
|
||||||
override fun start(scope: CoroutineScope): Job {
|
override fun start(scope: CoroutineScope): Job {
|
||||||
val supervisorScope = scope.LinkedSupervisorScope()
|
val supervisorScope = scope.LinkedSupervisorScope()
|
||||||
supervisorScope.launchSafelyWithoutExceptions {
|
supervisorScope.launchLoggingDropExceptions {
|
||||||
(statesManager.getActiveStates().asFlow() + statesManager.onStartChain).subscribeSafelyWithoutExceptions(supervisorScope) {
|
(statesManager.getActiveStates().asFlow() + statesManager.onStartChain).subscribeSafelyWithoutExceptions(
|
||||||
|
supervisorScope
|
||||||
|
) {
|
||||||
supervisorScope.launch { performStateUpdate(Optional.absent(), it, supervisorScope) }
|
supervisorScope.launch { performStateUpdate(Optional.absent(), it, supervisorScope) }
|
||||||
}
|
}
|
||||||
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(supervisorScope) {
|
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(supervisorScope) {
|
||||||
@@ -140,7 +142,7 @@ open class DefaultStatesMachine <T: State>(
|
|||||||
statesJobsMutex.withLock {
|
statesJobsMutex.withLock {
|
||||||
val stateInMap = statesJobs.keys.firstOrNull { stateInMap -> stateInMap == removedState }
|
val stateInMap = statesJobs.keys.firstOrNull { stateInMap -> stateInMap == removedState }
|
||||||
if (stateInMap === removedState) {
|
if (stateInMap === removedState) {
|
||||||
statesJobs[stateInMap] ?.cancel()
|
statesJobs[stateInMap]?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.ktor.client
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.MPPFile
|
import dev.inmo.micro_utils.common.MPPFile
|
||||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.ktor.common.TemporalFileId
|
import dev.inmo.micro_utils.ktor.common.TemporalFileId
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.content.*
|
import io.ktor.client.content.*
|
||||||
@@ -27,7 +27,7 @@ suspend fun tempUpload(
|
|||||||
val request = XMLHttpRequest()
|
val request = XMLHttpRequest()
|
||||||
request.responseType = XMLHttpRequestResponseType.TEXT
|
request.responseType = XMLHttpRequestResponseType.TEXT
|
||||||
request.upload.onprogress = {
|
request.upload.onprogress = {
|
||||||
subscope.launchSafelyWithoutExceptions { onUpload.onProgress(it.loaded.toLong(), it.total.toLong()) }
|
subscope.launchLoggingDropExceptions { onUpload.onProgress(it.loaded.toLong(), it.total.toLong()) }
|
||||||
}
|
}
|
||||||
request.onload = {
|
request.onload = {
|
||||||
if (request.status == 200.toShort()) {
|
if (request.status == 200.toShort()) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.ktor.client
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.MPPFile
|
import dev.inmo.micro_utils.common.MPPFile
|
||||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.content.*
|
import io.ktor.client.content.*
|
||||||
import io.ktor.http.Headers
|
import io.ktor.http.Headers
|
||||||
@@ -66,7 +66,7 @@ actual suspend fun <T> HttpClient.uniUpload(
|
|||||||
}
|
}
|
||||||
request.responseType = XMLHttpRequestResponseType.TEXT
|
request.responseType = XMLHttpRequestResponseType.TEXT
|
||||||
request.upload.onprogress = {
|
request.upload.onprogress = {
|
||||||
subscope.launchSafelyWithoutExceptions { onUpload.onProgress(it.loaded.toLong(), it.total.toLong()) }
|
subscope.launchLoggingDropExceptions { onUpload.onProgress(it.loaded.toLong(), it.total.toLong()) }
|
||||||
}
|
}
|
||||||
request.onload = {
|
request.onload = {
|
||||||
if (request.status == 200.toShort()) {
|
if (request.status == 200.toShort()) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package dev.inmo.micro_utils.ktor.server
|
|||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import dev.inmo.micro_utils.common.FileName
|
import dev.inmo.micro_utils.common.FileName
|
||||||
import dev.inmo.micro_utils.common.MPPFile
|
import dev.inmo.micro_utils.common.MPPFile
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.ktor.common.DefaultTemporalFilesSubPath
|
import dev.inmo.micro_utils.ktor.common.DefaultTemporalFilesSubPath
|
||||||
import dev.inmo.micro_utils.ktor.common.TemporalFileId
|
import dev.inmo.micro_utils.ktor.common.TemporalFileId
|
||||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||||
@@ -44,7 +44,7 @@ class TemporalFilesRoutingConfigurator(
|
|||||||
filesMap: MutableMap<TemporalFileId, MPPFile>,
|
filesMap: MutableMap<TemporalFileId, MPPFile>,
|
||||||
filesMutex: Mutex,
|
filesMutex: Mutex,
|
||||||
onNewFileFlow: Flow<TemporalFileId>
|
onNewFileFlow: Flow<TemporalFileId>
|
||||||
): Job = scope.launchSafelyWithoutExceptions {
|
): Job = scope.launchLoggingDropExceptions {
|
||||||
while (currentCoroutineContext().isActive) {
|
while (currentCoroutineContext().isActive) {
|
||||||
val filesWithCreationInfo = filesMap.mapNotNull { (fileId, file) ->
|
val filesWithCreationInfo = filesMap.mapNotNull { (fileId, file) ->
|
||||||
fileId to ((Files.getAttribute(file.toPath(), "creationTime") as? FileTime) ?.toMillis() ?: return@mapNotNull null)
|
fileId to ((Files.getAttribute(file.toPath(), "creationTime") as? FileTime) ?.toMillis() ?: return@mapNotNull null)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.cache.full
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
@@ -116,7 +116,7 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
|||||||
CRUDRepo<ObjectType, IdType, InputValueType> {
|
CRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.cache.full
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
@@ -141,7 +141,7 @@ open class FullKeyValueCacheRepo<Key,Value>(
|
|||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.cache.full
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
@@ -210,7 +210,7 @@ open class FullKeyValuesCacheRepo<Key,Value>(
|
|||||||
WriteKeyValuesRepo<Key, Value> by parentRepo {
|
WriteKeyValuesRepo<Key, Value> by parentRepo {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.cache.full.direct
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
@@ -82,7 +82,7 @@ open class DirectFullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
|||||||
CRUDRepo<ObjectType, IdType, InputValueType> {
|
CRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.cache.full.direct
|
package dev.inmo.micro_utils.repos.cache.full.direct
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
@@ -117,7 +117,7 @@ open class DirectFullKeyValueCacheRepo<Key, Value>(
|
|||||||
DirectFullReadKeyValueCacheRepo<Key, Value>(parentRepo, kvCache, locker) {
|
DirectFullReadKeyValueCacheRepo<Key, Value>(parentRepo, kvCache, locker) {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.cache.full.direct
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.common.*
|
import dev.inmo.micro_utils.common.*
|
||||||
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
import dev.inmo.micro_utils.coroutines.SmartRWLocker
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||||
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
import dev.inmo.micro_utils.coroutines.withReadAcquire
|
||||||
import dev.inmo.micro_utils.coroutines.withWriteLock
|
import dev.inmo.micro_utils.coroutines.withWriteLock
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
@@ -145,7 +145,7 @@ open class DirectFullKeyValuesCacheRepo<Key,Value>(
|
|||||||
WriteKeyValuesRepo<Key, Value> by parentRepo {
|
WriteKeyValuesRepo<Key, Value> by parentRepo {
|
||||||
init {
|
init {
|
||||||
if (!skipStartInvalidate) {
|
if (!skipStartInvalidate) {
|
||||||
scope.launchSafelyWithoutExceptions {
|
scope.launchLoggingDropExceptions {
|
||||||
if (locker.writeMutex.isLocked) {
|
if (locker.writeMutex.isLocked) {
|
||||||
initialInvalidate()
|
initialInvalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user