File tree 1 file changed +4
-21
lines changed
core/src/main/scala/scala/scalanative/loop
1 file changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -11,31 +11,14 @@ object EventLoop {
11
11
val loop : LibUV .Loop = uv_default_loop()
12
12
13
13
// Schedule loop execution after main ends
14
- scalanative.concurrent.NativeExecutionContext .queue.execute(
15
- new Runnable {
16
- def run (): Unit = EventLoop .run()
17
- }
18
- )
19
-
20
- // Reference to the private queue of scala.scalanative.runtime.ExecutionContext
21
- private val queue : mutable.ListBuffer [Runnable ] = {
22
- val executionContextPtr =
23
- fromRawPtr[Byte ](castObjectToRawPtr(NativeExecutionContext ))
24
- val queuePtr = ! ((executionContextPtr + 8 ).asInstanceOf [Ptr [Ptr [Byte ]]])
25
- castRawPtrToObject(toRawPtr(queuePtr))
26
- .asInstanceOf [mutable.ListBuffer [Runnable ]]
27
- }
14
+ NativeExecutionContext .queue.execute { () => EventLoop .run() }
28
15
29
16
def run (): Unit = {
17
+ // scala.scalanative package private queue containing WorkStealing API
18
+ val queue = NativeExecutionContext .queueInternal
30
19
while (uv_loop_alive(loop) != 0 || queue.nonEmpty) {
31
20
while (queue.nonEmpty) {
32
- val runnable = queue.remove(0 )
33
- try {
34
- runnable.run()
35
- } catch {
36
- case t : Throwable =>
37
- NativeExecutionContext .queue.reportFailure(t)
38
- }
21
+ queue.stealWork(1 )
39
22
uv_run(loop, UV_RUN_NOWAIT )
40
23
}
41
24
uv_run(loop, UV_RUN_ONCE )
You can’t perform that action at this time.
0 commit comments