Skip to content

Commit a67305e

Browse files
committed
poll -> dequeue, remove onlyUnconfined parameter
1 parent b1751db commit a67305e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

kotlinx-coroutines-core/common/src/EventLoop.common.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal abstract class EventLoop : CoroutineDispatcher() {
5353
* (no check for performance reasons, may be added in the future).
5454
*/
5555
public open fun processNextEvent(): Long {
56-
val task = popNextTask() ?: return Long.MAX_VALUE
56+
val task = dequeueNextTask() ?: return Long.MAX_VALUE
5757
task.run()
5858
return nextTime
5959
}
@@ -67,16 +67,19 @@ internal abstract class EventLoop : CoroutineDispatcher() {
6767
}
6868

6969
public fun processUnconfinedEvent(): Boolean {
70-
val task = popUnconfinedTask() ?: return false
70+
val task = dequeueUnconfinedTask() ?: return false
7171
task.run()
7272
return true
7373
}
7474

75-
public fun popUnconfinedTask(): DispatchedTask<*>? =
75+
protected fun dequeueUnconfinedTask(): DispatchedTask<*>? =
7676
unconfinedQueue?.removeFirstOrNull()
7777

78-
protected open fun popNextTask(onlyUnconfined: Boolean = false): Runnable? =
79-
popUnconfinedTask()
78+
/**
79+
* Get the next event in this event loop, if there is one.
80+
*/
81+
protected open fun dequeueNextTask(): Runnable? =
82+
dequeueUnconfinedTask()
8083

8184
/**
8285
* Returns `true` if the invoking `runBlocking(context) { ... }` that was passed this event loop in its context
@@ -258,11 +261,8 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
258261
}
259262
}
260263

261-
override fun popNextTask(onlyUnconfined: Boolean): Runnable? {
262-
val unconfined = popUnconfinedTask()
263-
if (onlyUnconfined) {
264-
return unconfined
265-
}
264+
protected override fun dequeueNextTask(): Runnable? {
265+
val unconfined = dequeueUnconfinedTask()
266266
// unconfined events take priority
267267
if (unconfined != null) {
268268
return unconfined

kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal actual object DefaultExecutor : EventLoopImplBase(), Runnable {
6565
if (!notifyStartup()) return
6666
while (true) {
6767
Thread.interrupted() // just reset interruption flag
68-
val nextTask = popNextTask()
68+
val nextTask = dequeueNextTask()
6969
if (nextTask != null) {
7070
shutdownNanos = Long.MAX_VALUE
7171
nextTask.run()

0 commit comments

Comments
 (0)