MMO game server brain loop
g_server.receiveData();


Does this actually handle all of the message parsing?

As in: Is it really necessary to handle the full netcode in the main thread?

At least unpacking and sorting all inputs to a thread safe queues (e.g. lockfree queue from boost) with unresolved, symbolic references should be easily possible inside the worker threads handling the connections.

Validation of conflicting inputs, or orphaned references can't be avoided in the main loop. But parsing the packages and preliminary filtering can.



releasePointersCounter += delay;
if (releasePointersCounter &gt;= 1000) {
    // This function simply calls a "delete" to removed objects from the game
    releaseObjects();
}


Not using C++11 shared pointers with builtin reference counting? Respectively, any specific reason (like cyclic references) which would prevent these from working?



// Sends all pending packets to be sent to active connections
g_server.sendAllData();


I must assume the world state, respectively the list of updates is not buffered, so this reads from the live game state?

Writing out all changes to the game state to a transaction log (with all dangling pointers resolved, implemented as a list with a single producer and multiple non-consuming iterators), and then walking the transaction log for each active connection asynchronously removes this load from the main loop as well.

There is no good reason why this should be allowed to stall the main loop.



int64_t connectionsTimeCounter = 0;
int64_t decayTimeCounter = 0;
int64_t releasePointersCounter = 0;
int64_t creaturesTimeCounter = 0;


Why are these variables write-only, apart from the initial check when to run the corresponding logic first? Respectively why does the main loop wait a full second before starting any of the workers at all?