File tree 1 file changed +24
-1
lines changed
core/kotlinx-coroutines-core/src
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -315,4 +315,27 @@ internal class BlockingEventLoop(
315
315
override val thread : Thread
316
316
) : EventLoopImplBase()
317
317
318
- internal actual fun createEventLoop (): EventLoop = BlockingEventLoop (Thread .currentThread())
318
+ internal actual fun createEventLoop (): EventLoop = BlockingEventLoop (Thread .currentThread())
319
+
320
+ /* *
321
+ * Processes next event in the current thread's event loop.
322
+ *
323
+ * The result of this function is to be interpreted like this:
324
+ * * `<= 0` -- there are potentially more events for immediate processing;
325
+ * * `> 0` -- a number of nanoseconds to wait for the next scheduled event;
326
+ * * [Long.MAX_VALUE] -- no more events, or was invoked from the wrong thread.
327
+ *
328
+ * Sample usage of this function:
329
+ *
330
+ * ```
331
+ * while (waitingCondition) {
332
+ * val time = processNextEventInCurrentThread()
333
+ * LockSupport.parkNanos(time)
334
+ * }
335
+ * ```
336
+ *
337
+ * @suppress **This an internal API and should not be used from general code.**
338
+ */
339
+ @InternalCoroutinesApi
340
+ public fun processNextEventInCurrentThread (): Long =
341
+ ThreadLocalEventLoop .currentOrNull()?.processNextEvent() ? : Long .MAX_VALUE
You can’t perform that action at this time.
0 commit comments