mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Use Dispatchers.IO.limitedParallelism in SearchViewModel to prevent thread leak (#4036)
This commit is contained in:
+2
-3
@@ -8,8 +8,8 @@ import androidx.lifecycle.viewModelScope
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -27,7 +27,6 @@ import tachiyomi.domain.manga.interactor.GetManga
|
||||
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
abstract class SearchViewModel(
|
||||
initialState: State = State(),
|
||||
@@ -48,7 +47,7 @@ abstract class SearchViewModel(
|
||||
state.update(function)
|
||||
}
|
||||
|
||||
private val coroutineDispatcher = Executors.newFixedThreadPool(5).asCoroutineDispatcher()
|
||||
private val coroutineDispatcher = Dispatchers.IO.limitedParallelism(5)
|
||||
private var searchJob: Job? = null
|
||||
|
||||
private val enabledLanguages = sourcePreferences.enabledLanguages.get()
|
||||
|
||||
Reference in New Issue
Block a user