lua-users home
lua-l archive

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




On Sun, Jul 17, 2011 at 11:53 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
* Gaspard Bucher:

> The Lua state processes a single operation at a time (no concurrency).
> Example of such operations (for the same Lua state) can be:

>   1. Receive message from network ===> update state ==> post reply
>   2. Receive notification from OS (file changed, mdns discovery, etc)
>   3. Receive a command from GUI (redraw window, mouse event, keyboard event,
> etc)
>   4. Trigger function from scheduler (pthread based timer)

This description is already heavily titled to an event-based approach.
You don't need coroutines at all for that.

The question of threads or coroutines arises when the reaction to an
event triggers further external interaction, such as posting messages
to several peers and acting on their replies.  If this is not
necessary, it's probably best to stick to the event-based approach.

GUIs are a bit of a thorny issue.  Events certainly have their
weaknesses, but it's a model that's been used for a while, and it
works with several underlying implementations.


Thanks for the feedback Florian. I needed some reassurance: global mutex are so out of fashion nowadays that I felt I must be stupid or misunderstanding something important for deciding to use one. If we want to handle multiple event sources, there must be some kind of gate between these sources and the Lua state and the simplest of such gates is a mutex, right ?

Gaspard
--

                                                               Gaspard