4 ms·
FWIW there are numerous libraries available for OS threads in Lua. Some are low-level, directly binding the OS threading API[1], some are high-level[2], support
by MattJ100 15y ago
FWIW there are numerous libraries available for OS threads in Lua. Some are low-level, directly binding the OS threading API[1], some are high-level[2], supporting message passing and atomic counters, etc.
[1]: https://github.com/Neopallium/lua-llthreads https://github.com/Neopallium/lua-llthreads
[2]: http://kotisivu.dnainternet.net/askok/bin/lanes/ http://kotisivu.dnainternet.net/askok/bin/lanes/
- chubot 15y agoRight, but this is different than Python and Ruby's threading, where threads can share state because they have a global interpreter lock. Lua has no such thing so both of those packages have to use message passing, which I think is good but not convenient in a lot of cases. Even though they are using threads, there is one Lua state per thread, so your threads have to serialize everything before communicating. As mentioned in the PIL book, they are better termed "Lua Processes" even though they are implemented using OS threads.