lua-users home
lua-l archive

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

On Tue Oct 31, 2023 at 4:20 AM EDT, Sean Conner wrote:
>   I don't know.  I do have code that may do what you want, but it involves
> several modules working together, and is operating system specific.  I use
> it mostly for network services.

Thanks for sharing! If my sleepy brain is comprehending it properly,
there's a single codebase that includes both the coroutines that handle
the events and the event loop itself. In other words, if a developer
is looking at one of those components they have to care about the
internals of the other as well. My intended usecase, which I could've
gone into detail initially, it's my fault for being overly vague, is
where a program has a plugin system, and events in a program can be
interacted with by the plugins. I haven't actually written most of it yet
but it's a Wayland compositor, and how it'll probably work is, a plugin
can have a Lua function be run in response to an event in the program.
That plugin API includes some functions that might need to wait for
something to happen internally in the program. So a Lua routine might be
started in response to a key being pressed, and might stay around until
a window is created because the plugin wants to do something with it,
for example.

This being a plugin interface is why I gave the previous requirement of
"It has to work even inside of a coroutine created within the plugin
script". The plugin shouldn't have to care about the implementation
details of the API, and if the API used coroutines to wait for things
then the plugins themselves wouldn't be able to with the way coroutines
in Lua seem to work currently.