Lagoon
Joined: 05 Mar 2006 Posts: 118 Location: Italy
|
Posted: Fri Nov 03, 2006 10:39 am Post subject: |
|
|
A very nice tutorial, personally I use this system to avoid long critical blocks, which would be otherwise required by some of the gameplay systems I need for my server. I'm talking about something like 400 lines of code which alter, with a complex logic, a data altered by other scripts too. Doing this critically is pure madness. So I use a queue handler, like Marilla explained. I don't use it as a replace for all critical test&sets
I critical test&set with few lines of code (and not containing looping function or library functions such as EnumerateOnlineCharacter) can't harm your server, you'll notice no performance issue using it. But a long one can indeed make disasters to you performance when you have several instances of such scripts running at once. So, I suggest to analyze the different situations script by script and decide either to use critical test&set or to fire an event to the queue handler.
About the feedback... Again Marilla explained very well the two possibile solutions: feedback event or predictive assumption. They are both good solutions, and each one has its pros and cons which you can easilyimagine: sending an event and aiting for an answer event means you have a sensible delay between the time you request the alteration and you aknowledge it. Some applications can live with this, some can't. For example once I tryed to code an action system with queue handler event and feedback event. The pc can do only one action at a time, so the scripts which want to start an action fire an "ask action permission" event to the queue handler and wait for the answer. Testing this, the delay was too much even with only one online character, which means even with the queue of the queue handler completely empty. The only way to code such system is with a critical test&set. Which won't hurt your server, since they are 5 lines of code.
The "magic" of the queue handler if that it creates a sort of "selective" critical system. when you use set_critical(1) and set_critical(0) you halt EVERYTHING, thus giving a "global delay" to the whole server. with the queue handler you can halt only some kind of systems, those which use the same queue, while the other systems of the server may continue to run concurrently. And those systems are systems which benefit greatly from this: pcs and npcs movement, AIs, and so on... |
|