File tree 1 file changed +2
-3
lines changed
kotlinx-coroutines-core/jvm/src/scheduling
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ internal class WorkQueue {
121
121
var start = consumerIndex.value
122
122
val end = producerIndex.value
123
123
124
- while (start != end) {
124
+ while (start != end && blockingTasksInBuffer.value > 0 ) {
125
125
stolenTaskRef.element = tryExtractBlockingTask(start++ ) ? : continue
126
126
return TASK_STOLEN
127
127
}
@@ -141,7 +141,7 @@ internal class WorkQueue {
141
141
val start = consumerIndex.value
142
142
var end = producerIndex.value
143
143
144
- while (start != end) {
144
+ while (start != end && blockingTasksInBuffer.value > 0 ) {
145
145
val task = tryExtractBlockingTask(-- end)
146
146
if (task != null ) {
147
147
return task
@@ -151,7 +151,6 @@ internal class WorkQueue {
151
151
}
152
152
153
153
private fun tryExtractBlockingTask (index : Int ): Task ? {
154
- if (blockingTasksInBuffer.value == 0 ) return null
155
154
val arrayIndex = index and MASK
156
155
val value = buffer[arrayIndex]
157
156
if (value != null && value.isBlocking && buffer.compareAndSet(arrayIndex, value, null )) {
You can’t perform that action at this time.
0 commit comments