Skip to content

Commit e2ceda8

Browse files
committed
EventLoop pseudo-constructor is replaced with top-level fun
1 parent de238eb commit e2ceda8

File tree

1 file changed

+22
-13
lines changed
  • kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental

1 file changed

+22
-13
lines changed

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/EventLoop.kt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,36 @@ public interface EventLoop {
4242
*/
4343
public fun processNextEvent(): Long
4444

45+
/** @suppress **Deprecated **/
46+
@Deprecated(message = "Companion object to be removed, no replacement")
4547
public companion object Factory {
46-
/**
47-
* Creates a new event loop that is bound the specified [thread] (current thread by default) and
48-
* stops accepting new events when [parentJob] completes. Every continuation that is scheduled
49-
* onto this event loop unparks the specified thread via [LockSupport.unpark].
50-
*
51-
* The main event-processing loop using the resulting `eventLoop` object should look like this:
52-
* ```
53-
* while (needsToBeRunning) {
54-
* if (Thread.interrupted()) break // or handle somehow
55-
* LockSupport.parkNanos(eventLoop.processNextEvent()) // event loop will unpark
56-
* }
57-
* ```
58-
*/
48+
/** @suppress **Deprecated **/
49+
@Deprecated("Replaced with top-level function", level = DeprecationLevel.HIDDEN)
5950
public operator fun invoke(thread: Thread = Thread.currentThread(), parentJob: Job? = null): CoroutineDispatcher =
6051
EventLoopImpl(thread).apply {
6152
if (parentJob != null) initParentJob(parentJob)
6253
}
6354
}
6455
}
6556

57+
/**
58+
* Creates a new event loop that is bound the specified [thread] (current thread by default) and
59+
* stops accepting new events when [parentJob] completes. Every continuation that is scheduled
60+
* onto this event loop unparks the specified thread via [LockSupport.unpark].
61+
*
62+
* The main event-processing loop using the resulting `eventLoop` object should look like this:
63+
* ```
64+
* while (needsToBeRunning) {
65+
* if (Thread.interrupted()) break // or handle somehow
66+
* LockSupport.parkNanos(eventLoop.processNextEvent()) // event loop will unpark
67+
* }
68+
* ```
69+
*/
70+
public fun EventLoop(thread: Thread = Thread.currentThread(), parentJob: Job? = null): CoroutineDispatcher =
71+
EventLoopImpl(thread).apply {
72+
if (parentJob != null) initParentJob(parentJob)
73+
}
74+
6675
private const val DELAYED = 0
6776
private const val REMOVED = 1
6877
private const val RESCHEDULED = 2

0 commit comments

Comments
 (0)