public class EventLoopKt
| Modifier and Type | Method and Description |
|---|---|
static CoroutineDispatcher |
EventLoop(java.lang.Thread thread,
Job parentJob)
Creates a new event loop that is bound the specified thread (current thread by default) and
stops accepting new events when parentJob completes. Every continuation that is scheduled
onto this event loop unparks the specified thread via LockSupport.unpark.
|
public static CoroutineDispatcher EventLoop(java.lang.Thread thread, Job parentJob)
Creates a new event loop that is bound the specified thread (current thread by default) and stops accepting new events when parentJob completes. Every continuation that is scheduled onto this event loop unparks the specified thread via LockSupport.unpark.
The main event-processing loop using the resulting eventLoop object should look like this:
while (needsToBeRunning) {
if (Thread.interrupted()) break // or handle somehow
LockSupport.parkNanos(eventLoop.processNextEvent()) // event loop will unpark
}