File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 7
7
having to use ` try/catch ` or other exception handlers.
8
8
* Fixed a race in ` ArrayBroadcastChannel ` between ` send ` and ` openChannel ` invocations
9
9
(see #138 ).
10
+ * Fixed quite a rare race in ` runBlocking ` that resulted in ` AssertionError ` .
11
+ Unfortunately, cannot write a reliable stress-test to reproduce it.
10
12
* Updated Reactor support to leverage Bismuth release train
11
13
(contributed by @sdeleuze , see PR #141 )
12
14
Original file line number Diff line number Diff line change @@ -216,9 +216,6 @@ private class BlockingCoroutine<T>(
216
216
}
217
217
218
218
override fun afterCompletion (state : Any? , mode : Int ) {
219
- // signal termination to event loop (don't accept more tasks)
220
- if (privateEventLoop)
221
- (eventLoop as BlockingEventLoop ).isCompleted = true
222
219
// wake up blocked thread
223
220
if (Thread .currentThread() != blockedThread)
224
221
LockSupport .unpark(blockedThread)
@@ -235,7 +232,12 @@ private class BlockingCoroutine<T>(
235
232
timeSource.parkNanos(this , parkNanos)
236
233
}
237
234
// process queued events (that could have been added after last processNextEvent and before cancel
238
- if (privateEventLoop) (eventLoop as BlockingEventLoop ).shutdown()
235
+ if (privateEventLoop) (eventLoop as BlockingEventLoop ).apply {
236
+ // We exit the "while" loop above when this coroutine's state "isCompleted",
237
+ // Here we should signal that BlockingEventLoop should not accept any more tasks
238
+ isCompleted = true
239
+ shutdown()
240
+ }
239
241
timeSource.unregisterTimeLoopThread()
240
242
// now return result
241
243
val state = this .state
Original file line number Diff line number Diff line change @@ -265,7 +265,6 @@ internal abstract class ThreadEventLoop(
265
265
// reschedule the rest of delayed tasks
266
266
rescheduleAllDelayed()
267
267
}
268
-
269
268
}
270
269
271
270
private class EventLoopImpl (thread : Thread ) : ThreadEventLoop(thread) {
You can’t perform that action at this time.
0 commit comments