cc-tweaked / Cobalt

A re-entrant fork of LuaJ
Other
72 stars 13 forks source link

Cobolt lua command only exit application after long timeout #42

Closed itgenie98 closed 4 years ago

itgenie98 commented 4 years ago

Problem

Cobalt needs very long to end his process if the class org.squiddev.cobalt.cmd.lua is used. Even with simple hello world scripts:

print("hello world")

Measurements

Windows:

PS > Measure-Command {java -cp Cobalt-0.5.1-SNAPSHOT.jar org.squiddev.cobalt.cmd.lua ./helloworld.lua}

Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 0
Milliseconds      : 200
Ticks             : 602003290
TotalDays         : 0,00069676306712963
TotalHours        : 0,0167223136111111
TotalMinutes      : 1,00333881666667
TotalSeconds      : 60,200329
TotalMilliseconds : 60200,329

WSL

$> time java -cp Cobalt-0.5.1-SNAPSHOT.jar org.squiddev.cobalt.cmd.lua ./helloworld.lua
hello world
java -cp Cobalt-0.5.1-SNAPSHOT.jar org.squiddev.cobalt.cmd.lua   0.12s user 0.11s system 0% cpu 1:00.20 total

System Information

Cobalt commit 080368883a4b958315746896101578328b6c139f Java version:

SquidDev commented 4 years ago

Ahh. It appears the coroutine threads are still kicking around, and so the VM doesn't terminate until the thread-pool kills them.

I guess we should probably set them up to run as daemon threads instead, but might be worthwhile explicitly shutting down the thread pool when the process terminates.

SquidDev commented 4 years ago

Ahh. It appears the coroutine threads are still kicking around, and so the VM doesn't terminate until the thread-pool kills them.

I guess we should probably set them up to run as daemon threads instead, but might be worthwhile explicitly shutting down the thread pool once the input program has finished.