Skip to content

Commit

Permalink
Made it so that singleton deleted at exit could be turned off.
Browse files Browse the repository at this point in the history
  • Loading branch information
flippmoke committed Aug 11, 2015
1 parent b5dedd0 commit ab2855a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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 = ''
Expand Down
2 changes: 2 additions & 0 deletions include/mapnik/util/singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit ab2855a

Please sign in to comment.