lua-users home
lua-l archive

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


On 9/9/22 11:57, John Belmonte wrote:
I'm sharing a draft article "Structured concurrency and Lua (part 1)".

https://gist.github.com/belm0/4c6d11f47ccd31a231cde04616d6bb22


Very interesting! I wrote a coroutine base scheduler (https://github.com/xopxe/Lumen) but it was pre-to-be-closed.

How I would implement your first example would be using signals: all tasks emit a special signal when finishing, (and another when errore'd). So you'd start all tasks and then wait for finalization signals in a loop keeping track of who finished. Much more burdensome. All in all, I love the concept of using the scope of variables to control the lifetime of high-level objects.

As a detail I see you register signals with the scheduler, I registered "wait descriptors" and signals can be anything. A wait descriptor contains the set of signals you're waiting on, plus timeout, plus an optional signal buffer where they are stored while the program is waiting somewhere else. I wonder how would you handle waiting on several signals?


Jorge