/usr/include/stxxl/bits
NameSizeModeActions
algo/-0755rm
common/-0755rm
compat/-0755rm
containers/-0755rm
io/-0755rm
mng/-0755rm
stream/-0755rm
utils/-0755rm
config.h37370644editdlrm
config.h.in43730644editdlrm
defines.h36440644editdlrm
deprecated.h11610644editdlrm
libstxxl.h7520644editdlrm
msvc_compatibility.h10530644editdlrm
namespace.h6580644editdlrm
noncopyable.h10850644editdlrm
parallel.h63150644editdlrm
singleton.h22360644editdlrm
unused.h7930644editdlrm
verbose.h83920644editdlrm
version.h29740644editdlrm
Edit: /usr/include/stxxl/bits/singleton.h (2236B)
/*************************************************************************** * include/stxxl/bits/singleton.h * * Part of the STXXL. See http://stxxl.sourceforge.net * * Copyright (C) 2008, 2011 Andreas Beckmann * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) **************************************************************************/ #ifndef STXXL_SINGLETON_HEADER #define STXXL_SINGLETON_HEADER #include #include #include #include #include STXXL_BEGIN_NAMESPACE template class singleton : private noncopyable { typedef INSTANCE instance_type; typedef instance_type* instance_pointer; typedef volatile instance_pointer volatile_instance_pointer; static volatile_instance_pointer instance; static instance_pointer create_instance(); static void destroy_instance(); public: inline static instance_pointer get_instance() { if (!instance) return create_instance(); return instance; } }; template typename singleton::instance_pointer singleton::create_instance() { static mutex create_mutex; scoped_mutex_lock instance_write_lock(create_mutex); if (!instance) { instance = new instance_type(); if (destroy_on_exit) register_exit_handler(destroy_instance); } return instance; } template void singleton::destroy_instance() { instance_pointer inst = instance; //instance = NULL; instance = reinterpret_cast(unsigned_type(-1)); // bomb if used again delete inst; } template typename singleton::volatile_instance_pointer singleton::instance = NULL; STXXL_END_NAMESPACE #endif // !STXXL_SINGLETON_HEADER