File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11package scala .scalanative .loop
22import scala .scalanative .unsafe ._
3+ import scala .annotation .tailrec
34
45object EventLoop {
56 import LibUV ._ , LibUVConstants ._
@@ -20,14 +21,21 @@ object EventLoop {
2021 * - we check if they generated IO calls on
2122 * the event loop
2223 * - If it's the case we run libuv's event loop
23- * using UV_RUN_ONCE that blocks only once
24+ * using UV_RUN_ONCE until there are callbacks
25+ * to execute
2426 * - We run the default execution context again
2527 * in case the callbacks generated new Futures
2628 */
2729 def run (): Unit = {
30+ @ tailrec
31+ def runUv (): Unit = {
32+ val res = uv_run(loop, UV_RUN_ONCE )
33+ if (res != 0 ) runUv()
34+ }
35+
2836 scala.scalanative.runtime.loop()
2937 while (uv_loop_alive(loop) != 0 ) {
30- uv_run(loop, UV_RUN_ONCE )
38+ runUv( )
3139 scala.scalanative.runtime.loop()
3240 }
3341 uv_loop_close(loop)
You can’t perform that action at this time.
0 commit comments