From 6acf7c91a6f30f6b16bb54f4b2c173383c521149 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Wed, 8 Sep 2021 09:13:15 +0200 Subject: OptIn GlobalScope usage in SagasFramework --- .../kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sw-ui') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt index ea3fc26e..22377512 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt @@ -2,6 +2,7 @@ package org.luxons.sevenwonders.ui.redux.sagas import kotlinx.coroutines.* import kotlinx.coroutines.channels.BroadcastChannel +import kotlinx.coroutines.channels.Channel.Factory.BUFFERED import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import redux.Middleware @@ -14,7 +15,7 @@ class SagaManager( ) { private lateinit var context: SagaContext - private val actions = BroadcastChannel(16) + private val actions = BroadcastChannel(BUFFERED) fun createMiddleware(): Middleware = ::sagasMiddleware @@ -34,6 +35,7 @@ class SagaManager( monitor?.invoke(action) } + @OptIn(DelicateCoroutinesApi::class) // Ok because almost never suspends - if it does, we have bigger problems private fun handleAction(action: A) { GlobalScope.launch { actions.send(action) } } -- cgit