-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Redesign #171
API Redesign #171
Conversation
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:
However, LuaJ uses OS threads for coroutines:
Fixed in |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #171 +/- ##
============================================
+ Coverage 92.73% 96.55% +3.81%
- Complexity 847 912 +65
============================================
Files 43 44 +1
Lines 2368 2465 +97
Branches 281 286 +5
============================================
+ Hits 2196 2380 +184
+ Misses 125 61 -64
+ Partials 47 24 -23 ☔ View full report in Codecov by Sentry. |
And fix bugs found in LuaTableValue
Originally {@link #recycleReferences} was synchronized on mainThread. However, the synchronization is deemed unnecessary and was later removed. 1. Only {@link #checkStack} and {@link #gc} calls recycleReferences. 2. We ask the user to synchronize on mainThread whenever they try to use LuaJava in a multi-thread application. 3. {@link #gc} is only called by the user and should already under a synchronization block. 4. {@link #checkStack} is used by lots of member functions in AbstractLua, but: - When it is called by the user, the user should do the synchronization instead. - When it is called from the Lua side via {@link JuaAPI}, either: - The user is calling, for example, {@link #run}, and synchronizes already on mainThread; - The call comes from a Java proxy object, which also synchronizes on mainThread. Notably, adding a synchronization block will make LuaJ coroutines malfunction: - The user synchronized on mainThread; - The user then called {@link #run} to execute a snippet to call a coroutine; - LuaJ created a Java thread for the coroutine; - Now, if the coroutine ever calls {@link #recycleReferences} (with, e.g., any stack operation), the two threads now deadlocks. The removal of the synchronization block should fix the issue above.
Handles the case when a proxy object is used on the Lua side.
- Remove duplicates of lua_pcall functions - Remove luaL_gsub
- Also fix AndroidScriptTest
To work around a timeout caused by ReactiveCircus/android-emulator-runner/issues/385
closes #169
Planned Changes
Probably not I guess?
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