lua-users home
lua-l archive

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


> From: Sean Conner <sean@conman.org> 

> By "independent Lua states"...

Each state is created wih lua_newstate(). There is a single event loop thread managing all states dispatching events to the various states. There can be 1,000s of these states running which means having a loop thread per state isn't scalable.

> I can't shake the feeling that your timer events abstraction isn't quite
> right, but I can't quite say why.

It's entirely possible but given my requirements ( using libevent, supporting multiple states on a single thread ) I don't see a way to make the callbacks work without stashing Lua states somewhere to reuse later.

Thanks for the examples. To be honest what I'm trying to determine is if it's possible to safely use coroutines given my current architecture. At the moment it's not really feasible for me to completely rearchitect the system - it's been deployed on 100,000+ customer sites and has proven to be stable when coroutines are not in use. Of course I'm not claiming it was implemented without issues or concerns - just that changing the behavior or introducing new bugs isn't worth the risk - let alone the effort that would be required to do so. 

If the answer is 'no, there is no way to use coroutines - you should have thought about that 15 years ago when designing 😊' that's fine - it just means I should probably remove the coroutine module from my Lua state so users don't get themselves into trouble. Allowing users to use coroutines would be really powerful which is why I'm looking into it. 

John