From ab2855a130c9f0fce5f24d700a66576c189cc3e6 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 11 Aug 2015 11:34:35 -0500 Subject: [PATCH] Made it so that singleton deleted at exit could be turned off. --- SConstruct | 4 ++++ include/mapnik/util/singleton.hpp | 2 ++ 2 files changed, 6 insertions(+) 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 } } }