lua-users home
lua-l archive

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


On Saturday, February 25, 2023 at 12:42:00 PM CST, Frank Mitchell \
<frank_mitchell_us@yahoo.com> wrote:

... sorry, I do not really understand your post.

I think for creating tasks / coroutines / threads, there are always
very many different ways to accomplish, and Lua as the "basic
interpreter language" can not do much more to present the basic frame
"to make it possible".

... if you want to use this for special applications, this always will
depend very much on applications and CPU system etc. (e. g. single
core CPU / multi core CPU / further things).

... to avoid "discussing beneath each other" maybe it is better if you
can describe your application, what you want to do with your tasks /
thread / coroutine scheme... .

(my tasks are based on some Lua function, so e. g. they would end, if
this Lua function is finished. The Lua user also can use a "loop
infinite function", if a sort of "sleep function" is invoked in
regular intervals. Further on task creation, the Lua user can define a
"maximum task run time", if this is needed. Further of course the task
can be stopped earlier by the Lua user.)

The Lua thread switching is done exactly like described in the C -
Thread chapter of PiL book of Roberto.

I only used two "Lua standard tricks", the first quite obvious, the
seond really depends on your application:
- after creating a new Lua thread on the Lua base state, the Lua
Thread should popped again from the Lua Base State stack, and instead
saved in the Lua Registry (until the task is closed).
- you have to think carefully, how to handle communication events with
"Lua string commands" (handeled by lua_pcallp), which do NOT arrive
through Lua, but through some "external events" - lua_pcallp should be
invoked only with a resumed Lua thread... you cannot invoke this from
Lua Base state... . You have to think about this, but to discuss this,
it is better to be sure about the application first.

PS: I hope this "comes through to Lua list" (I strangely only see your
post in MARC, but not in my Gmail account...).