26.08.2013, 02:46
Threading means that the plugin will go and run the query while allowing your script to resume execution.
Scenario:
Scenario:
You have two servers running the same gamemode, but using a MySQL server to store common data. In this case we will be handling player house data. You want this data to be loaded into the game mode all the time so that if a player buys a house on server A, server B will also show the house icon. Well if you're running a fairly popular server then you will end up having a lot of housing data. You want this data synchronized about every minute (for purpose of this example), however this is causing much lag while the plugin is going to the MySQL server to fetch the data. The script is waiting for the plugin to get the data before it can do anything else. So player updates are frozen during this time.
This is where threaded queries would help out. If you were to launch a threaded query to fetch the house data the plugin would run the query, while allowing the script to execute. Once the query has ran and the plugin has all the data, it will execute the specified callback in the script. Once this callback gets executed then your script will get all the data from the query, and you can process it as efficiently as you can.Any questions?