File tree 1 file changed +22
-0
lines changed
common/kotlinx-coroutines-core-common/src
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -129,3 +129,25 @@ internal object ThreadLocalEventLoop {
129
129
130
130
internal expect fun createEventLoop (): EventLoop
131
131
132
+ /* *
133
+ * Processes next event in the current thread's event loop.
134
+ *
135
+ * The result of this function is to be interpreted like this:
136
+ * * `<= 0` -- there are potentially more events for immediate processing;
137
+ * * `> 0` -- a number of nanoseconds to wait for the next scheduled event;
138
+ * * [Long.MAX_VALUE] -- no more events, or was invoked from the wrong thread.
139
+ *
140
+ * Sample usage of this function:
141
+ *
142
+ * ```
143
+ * while (waitingCondition) {
144
+ * val time = processNextEventInCurrentThread()
145
+ * LockSupport.parkNanos(time)
146
+ * }
147
+ * ```
148
+ *
149
+ * @suppress **This an internal API and should not be used from general code.**
150
+ */
151
+ @InternalCoroutinesApi
152
+ public fun processNextEventInCurrentThread (): Long =
153
+ ThreadLocalEventLoop .currentOrNull()?.processNextEvent() ? : Long .MAX_VALUE
You can’t perform that action at this time.
0 commit comments