lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Jan 28, 2020 at 11:05 AM Viacheslav Usov <via.usov@gmail.com> wrote:
On Mon, Jan 27, 2020 at 9:24 PM Archie Cobbs <archie.cobbs@gmail.com> wrote:

> STEP 1: Add a new header "lnbposix.h" to Lua.

This won't work for an important class of libraries known as "wrappers" or "bindings", i.e., libraries that expose (to Lua) the functionality of another library written in some other language. Even if the latter language is C or C++. With shared libraries this is just not possible, full stop.

With static libraries, you would have to modify a library that has nothing to do with Lua with something Lua-specific. First of all, this just does not look right conceptually. Second, the task might just be too difficult. Especially considering that those libraries might depend on more libraries, as is frequently the case.

Correct...

To restate what you're saying: this technique only works if the blocking call is part of the Lua C module itself, where it can be wrapped, but not if the blocking call is "indirect", i.e., invoked by some other unrelated library on which the C module depends and therefore inaccessible to "wrapping".
 
So this approach is not "composable".

More accurate would be to say that it's composable, but only one level deep.

So for example it works fine for a C module that provides a socket library. But if a C module uses libcurl to do network I/O or something then it doesn't help.

This is part of the trade-off with this idea, which is just trying to take an incremental step.

The only way I can see to jump directly to complete composability for non-blocking would be using pthreads (or equivalent), while somehow forcing it into non-preemptive mode. Unfortunately, that doesn't seem possible (at least, not portably).

-Archie

--
Archie L. Cobbs