--
You received this message because you are subscribed to a topic in the Google Groups "lua-l" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lua-l/QWXul3NUY1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lua-l+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lua-l/20240426000511.GG21073%40brevard.conman.org.
> It seems that this is monkeypatching various Lua functions to yield at
appropriate spots (mainly I/O).
Yup, but it's only the application (or tests) that actually call the monkey patch -- effectively switching the "mode" of the entire language with very little code difference.
> I think I need to see a real example here, not the test code. I'm having
a hard time following how this is used.
TLDR; I enjoy writing small (and eventually) well-tested libraries which make otherwise complex problems easier to implement. I want these libraries to work in a multitude of use-cases, especially both blocking and non-blocking.
Let's say you wanted to write a text editor or similar. In your editor you want to depend on a nifty library like LinesFile because the parser (for syntax highlighting) depends on it
https://github.com/civboot/civlua/blob/main/lib/ds/ds/file.lua#L32
The actual file handle depends on whatever comes out of io.open, so it will block unless monkey patched. If you implement something like FDT (fd thread) then you can swap them out (see fd.c and fd.lua for full implementation. Basically: execute reads/etc in another thread and yield until complete)
https://github.com/civboot/civlua/blob/a951f12395c2bf7c0197eb92a2efe13314d3dc72/lib/fd/fd.h#L26
Obviously we could also do dependency injection, but at that point this becomes more like a job and less like a hobby for me.
> the various select() functions don't work with files ...etc--
You received this message because you are subscribed to a topic in the Google Groups "lua-l" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lua-l/QWXul3NUY1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lua-l+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lua-l/20240426011130.GH21073%40brevard.conman.org.
Your method, of calling into another thread to do the I/O does work, but
to me, it's only a win if the file in question isn't cached in RAM, and once
it is, then the overhead of coordinating two threads seems like it will kill
any performance gains, but as always in these cases, measurements are
required (and difficult to do as it's hard to eject files from
cache---there's no API that I know of to do it under POSIX).
--
You received this message because you are subscribed to a topic in the Google Groups "lua-l" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lua-l/QWXul3NUY1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lua-l+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lua-l/CAO8R-xiSnB0BQDQ25oFhcjZvYzJOV_HpzvHiOMch%3DMQhD8rocQ%40mail.gmail.com.