I've got a game server. It creates number of instances of Game and adds them (Or a pointer to them? What's better? It has 10 ints and 5 other pointers, 10 member functions) to the vector. After that some events happen inside of the game e. g. game_ends. At this very moment the game should be deleted from the vector... What is the best way to achieve it?
The two ways we've come to are:
create an observer pattern. server will be an observer and game will dispatch an event to delete it.
set the game to
endedstate while server constantly scans the vector and deletes that games which are inendedstate.