mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-08 17:49:44 +00:00
fixes in actorAsync
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.micro_utils.coroutines
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.flow.consumeAsFlow
|
import kotlinx.coroutines.flow.consumeAsFlow
|
||||||
@@ -7,13 +8,15 @@ import kotlinx.coroutines.flow.consumeAsFlow
|
|||||||
fun <T> CoroutineScope.actorAsync(
|
fun <T> CoroutineScope.actorAsync(
|
||||||
channelCapacity: Int = Channel.UNLIMITED,
|
channelCapacity: Int = Channel.UNLIMITED,
|
||||||
markerFactory: suspend (T) -> Any? = { null },
|
markerFactory: suspend (T) -> Any? = { null },
|
||||||
|
logger: KSLog = KSLog,
|
||||||
block: suspend (T) -> Unit
|
block: suspend (T) -> Unit
|
||||||
): Channel<T> {
|
): Channel<T> {
|
||||||
val channel = Channel<T>(channelCapacity)
|
val channel = Channel<T>(channelCapacity)
|
||||||
channel.consumeAsFlow().subscribeAsync(this, markerFactory, block)
|
channel.consumeAsFlow().subscribeAsync(this, markerFactory, logger, block)
|
||||||
return channel
|
return channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Use standard actosAsync instead", ReplaceWith("actorAsync(channelCapacity, markerFactory, block = block)", "dev.inmo.micro_utils.coroutines.actorAsync"))
|
||||||
inline fun <T> CoroutineScope.safeActorAsync(
|
inline fun <T> CoroutineScope.safeActorAsync(
|
||||||
channelCapacity: Int = Channel.UNLIMITED,
|
channelCapacity: Int = Channel.UNLIMITED,
|
||||||
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||||
|
Reference in New Issue
Block a user