I think option 2 would be the best.
Because it will immediately start with receiving information when it's needed.
And option 2 might cause lagg.
Because it can't do anything with the Player thread.
|
So we're starting out with a basic winterlove type server. Which of the following would be the fastest? (Disregarding memory consumption or CPU time)
Code:#1: We do away with the "main" thread for processing, and when a "incoming" thread receives a full packet, it acquires a lock on all players and processes the packet. Now, the main thread can focus on updating the players and not IO or tending to packets.
Code:#2: We make an "incoming" thread to handle incoming data, and it reads it into a byte array. Now when the "main" thread processes packets, it has the data already instead of having to deal with IO.
I think option 2 would be the best.
Because it will immediately start with receiving information when it's needed.
And option 2 might cause lagg.
Because it can't do anything with the Player thread.
number 2
This doesn't make sense.
The main thread only listens for incoming connections and accepts them. After it accepts a client, it creates a new thread to handle it. It's the newly created thread that handles the client, not the main thread.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |