Made it so that singleton deleted at exit could be turned off.

This commit is contained in:
Blake Thompson 2015-08-11 11:34:35 -05:00
parent b5dedd0e69
commit ab2855a130
2 changed files with 6 additions and 0 deletions

View file

@ -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 = ''

View file

@ -119,8 +119,10 @@ template <typename T,
{
tmp = CreatePolicy<T>::create();
pInstance_.store(tmp, std::memory_order_release);
#ifndef MAPNIK_NO_ATEXIT
// register destruction
std::atexit(&DestroySingleton);
#endif
}
}
}