Real multitasking support/Multithreading support
nift4 opened this issue ยท 4 comments
This is not breaking something because this isn't used by default, but I'm sure there are some great use cases like a real multitasking OS :)
Coroutines are a very expressive control primitive and I'm sure you can figure something out, perhaps using the debug
API as well. The event-driven, cooperative model works very well for practical applications of CC.
What actual gain would adding preemptive (cooperative multitasking is just as "real" as preemptive multitasking) lead to? Because I can see several downsides, not the least of which is implementation complexity and additional maintainership burden.
Lua is very much designed as a single-threaded VM, and as such lacks many of the concurrency primitives one would need (such as locks) for a sane multi-threaded system.
The cleanest solution would be to do something like Lua lanes, and allow running multiple separate processes which can pass messages to each other. However, there's an "easy" way to do that already - multiple computers!