Skip to content

Commit 3ce38c6

Browse files
authored
Fix crash in CoroutineQueue (#421)
1 parent 501081a commit 3ce38c6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

readium/shared/src/main/java/org/readium/r2/shared/util/CoroutineQueue.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class CoroutineQueue(
3131
private val scope: CoroutineScope =
3232
CoroutineScope(dispatcher + SupervisorJob())
3333

34+
private val tasks: Channel<Task<*>> = Channel(Channel.UNLIMITED)
35+
3436
init {
3537
scope.launch {
3638
for (task in tasks) {
@@ -79,8 +81,6 @@ public class CoroutineQueue(
7981
scope.cancel(cause)
8082
}
8183

82-
private val tasks: Channel<Task<*>> = Channel(Channel.UNLIMITED)
83-
8484
private class Task<T>(
8585
val task: suspend () -> T,
8686
val deferred: CompletableDeferred<T>? = null

test-app/src/main/java/org/readium/r2/testapp/utils/CoroutineQueue.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class CoroutineQueue(
2929
private val scope: CoroutineScope =
3030
CoroutineScope(dispatcher + SupervisorJob())
3131

32+
private val tasks: Channel<Task<*>> = Channel(Channel.UNLIMITED)
33+
3234
init {
3335
scope.launch {
3436
for (task in tasks) {
@@ -77,8 +79,6 @@ class CoroutineQueue(
7779
scope.cancel(cause)
7880
}
7981

80-
private val tasks: Channel<Task<*>> = Channel(Channel.UNLIMITED)
81-
8282
private class Task<T>(
8383
val task: suspend () -> T,
8484
val deferred: CompletableDeferred<T>? = null

0 commit comments

Comments
 (0)