Use CoroutineStart.ATOMIC in some cases
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.core.ui.util
|
package org.koitharu.kotatsu.core.ui.util
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineStart
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.NonCancellable
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -13,7 +14,7 @@ fun interface ReversibleHandle {
|
|||||||
suspend fun reverse()
|
suspend fun reverse()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default) {
|
fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default, CoroutineStart.ATOMIC) {
|
||||||
runCatchingCancellable {
|
runCatchingCancellable {
|
||||||
withContext(NonCancellable) {
|
withContext(NonCancellable) {
|
||||||
reverse()
|
reverse()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.history.domain
|
package org.koitharu.kotatsu.history.domain
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineStart
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.NonCancellable
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -30,7 +31,7 @@ class HistoryUpdateUseCase @Inject constructor(
|
|||||||
manga: Manga,
|
manga: Manga,
|
||||||
readerState: ReaderState,
|
readerState: ReaderState,
|
||||||
percent: Float
|
percent: Float
|
||||||
) = processLifecycleScope.launch(Dispatchers.Default) {
|
) = processLifecycleScope.launch(Dispatchers.Default, CoroutineStart.ATOMIC) {
|
||||||
runCatchingCancellable {
|
runCatchingCancellable {
|
||||||
withContext(NonCancellable) {
|
withContext(NonCancellable) {
|
||||||
invoke(manga, readerState, percent)
|
invoke(manga, readerState, percent)
|
||||||
|
|||||||
Reference in New Issue
Block a user