Register for your free account! | Forgot your password?

You last visited: Today at 23:17

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Logic?

Discussion on Logic? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2014
Posts: 194
Received Thanks: 52
Logic?

Hello guys,
I have a question regarding threads.
Shall i use a thread for each player? Like : stamina, flags, escorts **** like this.
Normal threads (1 for the whole server) : Monsters, Tournaments.

Opinions and why?
Thanks in advance.
iBotx is offline  
Old 05/30/2016, 19:44   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,192
In most cases, a thread-per-session model isn't going to work for a Conquer Online server (unless you plan on only hosting a handful of people). A thread is a separate path of execution that needs computation time on your processor. The more threads you have, the more processing time is split up and the more time taken in switching between those thread contexts. I'm not saying you can't overbook and have more threads than your processor cores, but one thread per player isn't going to stale; especially on a Raspberry Pi, if that's still on the table.
Spirited is offline  
Old 05/30/2016, 20:23   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,381
The more common setup I've seen is using a handful of worker threads and queueing work to thread safe collections to be processed.

Async sockets are going to be using a background threadpool to handle their data. You can then queue up waiting data to be processed. Often the work of processing will be split into a handful of worker threads to minimize context switching and to try to keep everything that could conflict on the same thread.


For example... lets say you have a thread that handles all database logic, it makes sense that when you go to save a value (lets say saving a character when they log out) to switch all of the work to that single database thread. it ensures that (hopefully) you avoid race conditions and you don't lock up a separate thread that might have other work waiting.

The same can be done for things like all entity updates (status effects, timed actions, etc), for monster background AI (NOT triggering the actual actions, just planning it out), for all battle or map functions, for packet processing or for a handful of other things.

This doesn't mean you don't have to take into account thread safety in your collections but you can at least try to limit the number of times that threads could be conflicting with eachother and try to split the work into manageable sections.

I'm not super familiar with how well thread priorities work but it's something you might want to look into as well. Things like saving to database, planning future monster movement paths and other stuff like that don't need to be as high priority as say... processing a player movement packet. By having them split to their own worker thread you may have the possibility of shifting around their priority (I'm guessing though that it may be best to leave that up to the OS to manage)
pro4never is offline  
Reply


Similar Threads Similar Threads
What are these logic?
06/20/2014 - Facebook - 0 Replies
It is the same for any cheats, leeched or not, the risk being patched once post here. This cannot be a reason to close the thread. And it is not true "thread's ...main purpose seems to be a place for leechers to insult each other.". It is only a few persons cause the flame. The flaming individual should be warns or punish, not the thread. btw, golpebaixo you should not insult others in the forum. Sadly, moderator Arby follow mexikant's and your logic.
Die Stämme Bot by Logic.
07/21/2013 - Coding Releases - 8 Replies
Hi com, ich wollte euch heute ein Projekt eines Freundes vorstellen (bei dem ich geholfen habe bzw. den Support übernehme) und zwar einen Die Stämme Bot. Der Bot ist zurzeit noch in der Testphase d.h., dass es noch Bugs gibt bzw. noch einige Funktionen kommen werden. Bot: Patched! Version: 1.0.2 Download: Anhang oder anomscript.forumprofi .de
Die Stämme Bot by Logic.
06/16/2013 - Freebies - 2 Replies
Hi com, ich wollte euch heute ein Projekt eines Freundes vorstellen (bei dem ich geholfen habe bzw. den Support übernehme) und zwar einen Die Stämme Bot. Der Bot ist zurzeit noch in der Testphase d.h., dass es noch Bugs gibt bzw. noch einige Funktionen kommen werden. Version: 1.0.2 Download: anomscript.forumprofi .de
My Logic Screen
04/16/2010 - EO PServer Hosting - 5 Replies
I Edited an old picture of a eo picture, Tell me if you think it looks likes on a scale 1-10 http://img11.imageshack.us/i/theloginscreen.png/



All times are GMT +1. The time now is 23:18.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.