[Plugin] Yet Another Lua Plugin
#7

Quote:
Originally Posted by narwn
View Post
thread single/multi?
I assume you inquire about the multithreading capabilities of the plugin. Since Lua is singlethreaded (like Pawn), and the server API is not thread-safe, there is no special way to execute Lua code in a different process thread. The only way is to use a plugin that offers multithreading (like PawnPlus) and invoke Lua code from a new thread (but note that some YALP packages are not thread-safe as well).

However, you can use Lua coroutines freely, and there are functions like async and timer.wait that help you run asynchronous code.

There is also timer.parallel which can execute any piece of Lua code, but pauses it after a given number of instructions, and resumes it on the next tick. If you want to execute a piece of code that can take a long time but without blocking the server (and without any corruption caused by calling thread-unsafe functions), you can use this function.

That being said, I do have an idea how to implement multi-threading in Lua, with the use of the already existing remote package. Nevertheless, I have not found a proper use case for this, and it would be fairly limited anyway (but 100 % thread-safe).
Reply


Messages In This Thread
Yet Another Lua Plugin - by IllidanS4 - 26.10.2018, 15:06
Re: Yet Another Lua Plugin - by IllidanS4 - 26.10.2018, 15:09
Re: Yet Another Lua Plugin - by IllidanS4 - 17.11.2018, 00:43
Re: Yet Another Lua Plugin - by lepegadore - 19.11.2018, 19:03
Re: Yet Another Lua Plugin - by IllidanS4 - 19.11.2018, 20:35
Re: Yet Another Lua Plugin - by narwn - 20.11.2018, 04:39
Re: Yet Another Lua Plugin - by IllidanS4 - 20.11.2018, 12:06
Re: Yet Another Lua Plugin - by IllidanS4 - 28.12.2018, 18:42
Re: Yet Another Lua Plugin - by IllidanS4 - 08.02.2019, 00:08
Re: Yet Another Lua Plugin - by Bolex_ - 08.02.2019, 17:03

Forum Jump:


Users browsing this thread: 1 Guest(s)