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 1
1
package scala .scalanative .loop
2
2
import scala .scalanative .unsafe ._
3
+ import scala .annotation .tailrec
3
4
4
5
object EventLoop {
5
6
import LibUV ._ , LibUVConstants ._
@@ -20,14 +21,21 @@ object EventLoop {
20
21
* - we check if they generated IO calls on
21
22
* the event loop
22
23
* - 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
24
26
* - We run the default execution context again
25
27
* in case the callbacks generated new Futures
26
28
*/
27
29
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
+
28
36
scala.scalanative.runtime.loop()
29
37
while (uv_loop_alive(loop) != 0 ) {
30
- uv_run(loop, UV_RUN_ONCE )
38
+ runUv( )
31
39
scala.scalanative.runtime.loop()
32
40
}
33
41
uv_loop_close(loop)
You can’t perform that action at this time.
0 commit comments