Closed gudzpoz closed 4 months ago
After adding more tests, LuaJ's approach to coroutines (by using OS threads) turns out to be problematic: it can deadlock.
In PUC-Rio Lua, all operations are executed a single thread:
synchronized @<thread-1> {
lua calls another coroutine {
lua access proxy objects {
synchronized @<thread-1> { // luajava proxies synchronizes to ensure thread safety
operations can be done since it it fine to nest sync-scopes in the same thread
}
}
}
}
However, LuaJ uses OS threads for coroutines:
synchronized @<thread-1> {
lua calls another coroutine {
here is @<thread-2> !!!
lua access proxy objects {
synchronized @<thread-2> { // deadlock here
unreachable~
}
}
}
}
However, after looking into the implementation of No, it's not.LuaThread
in LuaJ, it actually seems possible to re-implement coroutines with a single-threaded executor.
Fixed in 46ea2c3
(#171) and a24b929
(#171) .
Attention: Patch coverage is 99.69605%
with 1 lines
in your changes are missing coverage. Please review.
Project coverage is 96.55%. Comparing base (
f6872e0
) to head (09596f4
). Report is 1 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
...in/java/party/iroiro/luajava/luaj/LuaJNatives.java | 90.90% | 0 Missing and 1 partial :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
closes #169
Planned Changes
LuaValue
improvements.Map
interface implementation for tables.toProxy()
.LuaValue#close
and delegate the job fully to cleaners/finalizers.LuaFunction
to simplifyJFunction
usages.LuaThread::execute
toeval
to match JSR223 naming.Lua
interface improvements:LuaThread
interface, similar to aLuaValue
table).LuaNative
clean up.LuaJNatives
for more useless functions present in theLuaNative
interface.luaL_gsub
. Our bindings are mostly programmatically generated and include these functions. However,luaL_gsub
is just doing C string substitution (no, it does not involve any Lua) and should be safe to remove.luaL_gsub
.luaJ_pcall
.luaJ_metatable
.LuaNatives
public.java.catched
tojava.caught
.Non-API Changes