Tuesday 8 August 2017

Game Engine 08/08/17 - Messaging System Overhaul Part 2

My MessagePool class works the following way when allocating a message:
  1. Search for a free memory slot;
  2. Allocate on the slot found and mark the slot as occupied;
  3. Create a MessageHandle pointing to the slot location;
  4. Return the MessageHandle.
The MessageHandle class manages the amount of references its Message has. In the MessagePool's Clean() function, the MessagePool searches for messages with 0 references to them, and deallocates them, marking their slot as unoccupied. 

When passing around messages between EngineModules, the moment there are no more MessageHandles the message is deallocated.

In the next post I will write about the ConsoleModule & CommandModule classes.

No comments:

Post a Comment