Introduce new Decoder scope
This commit is contained in:
1 parent
4e4f77de90
commit
4d69bf2aba
2 files changed
+15
No files matched your search
@@ -106,6 +106,7 @@ public final class SpiderQueen implements Runnable {
|
||||
@Nullable
|
||||
private volatile Thread mQueenThread;
|
||||
private SpiderQueenWorker mWorkerScope;
|
||||
private SpiderQueenDecoder mDecoderScope;
|
||||
private boolean mStoped = false;
|
||||
|
||||
private SpiderQueen(@NonNull GalleryInfo galleryInfo) {
|
||||
@@ -118,6 +119,7 @@ public final class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
mWorkerScope = new SpiderQueenWorker(this);
|
||||
mDecoderScope = new SpiderQueenDecoder(this);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@@ -353,6 +355,8 @@ public final class SpiderQueen implements Runnable {
|
||||
|
||||
CoroutineScopeKt.cancel(mWorkerScope, null);
|
||||
mWorkerScope = null;
|
||||
CoroutineScopeKt.cancel(mDecoderScope, null);
|
||||
mDecoderScope = null;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.hippo.ehviewer.spider
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class SpiderQueenDecoder(private val queen: SpiderQueen) : CoroutineScope {
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.IO.limitedParallelism(2) + SupervisorJob()
|
||||
}
|
||||
Reference in new issue
Block a user