PenUltima Online

It is currently Fri Sep 05, 2008 11:13 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Queues Package: Stop Using set_critical() blocks!
PostPosted: Thu Nov 02, 2006 9:26 am 
Guide/Download removed. No longer available.


Last edited by Marilla on Sun Dec 17, 2006 8:54 am, edited 1 time in total.

Top
  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 6:39 am 
Offline

Joined: Sun Mar 05, 2006 7:25 am
Posts: 118
Location: Italy
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl