🛠️ Adjust parallelism for EPUB parser
* Increased parallelism to 3
This commit is contained in:
parent
7dd1a496de
commit
87b182709f
1 changed files with 2 additions and 3 deletions
|
|
@ -8,7 +8,6 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.coroutineScope
|
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.coroutines.yield
|
import kotlinx.coroutines.yield
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
|
|
@ -29,7 +28,7 @@ import kotlin.collections.set
|
||||||
private const val EPUB_TAG = "EPUB Parser"
|
private const val EPUB_TAG = "EPUB Parser"
|
||||||
private typealias Title = String
|
private typealias Title = String
|
||||||
|
|
||||||
private val dispatcher = Dispatchers.IO.limitedParallelism(2)
|
private val dispatcher = Dispatchers.IO.limitedParallelism(3)
|
||||||
|
|
||||||
class EpubTextParser @Inject constructor(
|
class EpubTextParser @Inject constructor(
|
||||||
private val documentParser: DocumentParser
|
private val documentParser: DocumentParser
|
||||||
|
|
@ -107,7 +106,7 @@ class EpubTextParser @Inject constructor(
|
||||||
): List<ReaderText> {
|
): List<ReaderText> {
|
||||||
|
|
||||||
val readerText = mutableListOf<ReaderText>()
|
val readerText = mutableListOf<ReaderText>()
|
||||||
coroutineScope {
|
withContext(Dispatchers.IO) {
|
||||||
val unformattedText = ConcurrentLinkedQueue<Pair<Int, List<ReaderText>>>()
|
val unformattedText = ConcurrentLinkedQueue<Pair<Int, List<ReaderText>>>()
|
||||||
|
|
||||||
// Asynchronously getting all chapters with text
|
// Asynchronously getting all chapters with text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue