-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Lua uvFifoListener ffi #1156
base: main
Are you sure you want to change the base?
Lua uvFifoListener ffi #1156
Conversation
…ync is folded later into UvFifoListener
Codecov ReportBase: 16.37% // Head: 16.38% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1156 +/- ##
=======================================
Coverage 16.37% 16.38%
=======================================
Files 362 363 +1
Lines 115794 115871 +77
=======================================
+ Hits 18962 18980 +18
- Misses 96832 96891 +59
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
src/lua/fileffi.lua
Outdated
|
||
_callback = function(fifo) end | ||
|
||
if cb ~= nil then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we check for cb == nil
before, this check isn't really useful.
Also, we're going to overwrite _callback
afterward. And it should be declared as local
.
@@ -73,6 +74,22 @@ LuaFile* subFile(LuaFile* wrapper, uint64_t start, int64_t size) { | |||
} | |||
LuaFile* uvFifo(const char* address, int port) { return new LuaFile(new PCSX::UvFifo(address, port)); } | |||
|
|||
LuaServer* uvFifoListener() {return new LuaServer(new PCSX::UvFifoListener());} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need a function to delete a LuaServer. It's not simple as it needs to schedule a stop if the server is running, and then delete in the async close callback.
src/lua/luafile.cc
Outdated
} | ||
|
||
void stopListener(LuaServer* server) { | ||
server->m_listener->stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need a status variable to avoid double stops. It needs to be "STARTED", "STOPPING", "STOPPED".
src/lua/fileffi.lua
Outdated
} | ||
-- Use a proxy instead of doing this on the wrapper directly using ffi.gc, because of a bug in LuaJIT, | ||
-- where circular references on finalizers using ffi.gc won't actually collect anything. | ||
debug.setmetatable(listener._proxy, { __gc = function() C.stopListener(listener._wrapper) end }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should (1) call the deleter of the class instead, and (2) it should free the callback in Lua.
Adds ability to spin up a uvFifoListener (similar to using uvFifo in Lua) but as a server instead of a client.