Skip to content

Commit 948baa4

Browse files
committed
Add comment to explain loop logic
1 parent ccc3e7b commit 948baa4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/loop.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ object EventLoop {
99
// Schedule loop execution after main ends
1010
scalanative.runtime.ExecutionContext.global.execute(
1111
new Runnable {
12+
/**
13+
* This is the implementation of the event loop
14+
* that integrates with libuv. The logic is the
15+
* following:
16+
* - First we run all Scala futures in the default
17+
* execution context
18+
* - Then in loop:
19+
* - we check if they generated IO calls on
20+
* the event loop
21+
* - If it's the case we run libuv's event loop
22+
* using UV_RUN_ONCE that blocks only once
23+
* - We run the default execution context again
24+
* in case the callbacks generated new Futures
25+
*/
1226
def run(): Unit = {
1327
scala.scalanative.runtime.loop()
1428
while (uv_loop_alive(loop) != 0) {

0 commit comments

Comments
 (0)