diff --git a/SConstruct b/SConstruct index 359801da3..b1c7f30b7 100644 --- a/SConstruct +++ b/SConstruct @@ -301,6 +301,7 @@ opts.AddVariables( ('HOST', 'Set the target host for cross compiling', ''), ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), + BoolVariable('NO_ATEXIT', 'Will prevent Singletons from being deleted atexit of main thread', 'False'), # http://www.scons.org/wiki/GoFastButton # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), @@ -1706,6 +1707,9 @@ if not preconfigured: if env['THREADING'] == 'multi': env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE') + if env['NO_ATEXIT']: + env.Append(CPPDEFINES = '-DMAPNIK_NO_ATEXIT') + # Mac OSX (Darwin) special settings if env['PLATFORM'] == 'Darwin': pthread = '' diff --git a/include/mapnik/util/singleton.hpp b/include/mapnik/util/singleton.hpp index 2c4040603..e77b25b40 100644 --- a/include/mapnik/util/singleton.hpp +++ b/include/mapnik/util/singleton.hpp @@ -119,8 +119,10 @@ template ::create(); pInstance_.store(tmp, std::memory_order_release); +#ifndef MAPNIK_NO_ATEXIT // register destruction std::atexit(&DestroySingleton); +#endif } } }