Quote:
Originally Posted by Korvacs
If your careful enough to avoid the multi-threading issues then your careful enough to design a socket system where its a practical impossibility for 2 packets be processed out of order using a multi-threaded packet handler.
Sorry, I don't see your argument. There's little evidence to support the claim unless you include people who don't know how to design a decent socket and packet handler. In which case the single threaded approach would likely fair no better.
|
Quote:
Originally Posted by SteveRambo
If you're just carelessly processing all your packets asynchronously, you might as well just make your entire project non thread-safe (no locks, no concurrent collections, etc.) and cross your fingers and hope nothing fucks up, really.
|
^
Honestly, packet processing should not be doing that much work. A Conquer server doesn't have to do any kind of advanced physics calculations or anything "heavy", really. It should really just be: "Input" verification, a few commands (like changing player position, status, money, attack, whatever), and generating some form of response. It should
not be anything heavy at all.
What I would do, if I were to ever write a server, which I'm not, I'd obviously async I/O and submit packets to a queue that is processed from a SINGLE, different thread. If I actually did some profiling and could prove that using a single thread for packet processing is not sufficient, then yes, I would probably start delegating the packet processing out to more threads and have different threads for different "categories" of packets, like packets that were accessing a player's position in one thread, maybe chat packets in another thread, etc., who knows. But I would
never design my server like that from the start. That's really unnecessary and, in my opinion, a huge overkill. Sure, you could and should probably design your server so you can actually make this change without too much effort, but that should come naturally as long as you follow basic OOP guidelines.