Global Object Manager – GOM – aka Singleton
I have code that deals with problems related to initialization of global objects (singletons).
1. Multi-threading – problems occurring in some singleton patterns based on the fact that local for a function or method static variables are not initialized in a thread safe manner
2. Initialization order – there is no multi-platform/multi-compiler standard way to control the global objects initialization order
3. Static linking of global objects code without need – some patterns result in global objects to be linked in the final executable, even if they are provided from static libraries and the code that uses them is not in use
4. Capability for easy replacement of a global implementation object with a mock object
I was struggling with shutdown issues in complex c++ application for years in several different projects. With the solution I come up a few years ago I have no issues in any project I have used it.
Note that the boost singleton pattern used for path_locale (boost filesystem path) is having the multi-thread issue I mentioned in point 1. This is a small test that demonstrates the problem: https://github.com/ggeorgiev/boost-filesystem-singletons/blob/master/filesystem-test/main.cpp
The code of the library is in: https://github.com/ggeorgiev/gom
There are 3 comments