http://stxxl.sourceforge.net
<beckmann@cs.uni-frankfurt.de>
http://www.boost.org/LICENSE_1_0.txt
#include <stxxl/bits/common/exithandler.h>
#include <stxxl/bits/namespace.h>
#ifndef STXXL_EXTERNAL_EXIT_HANDLER
#ifndef STXXL_NON_DEFAULT_EXIT_HANDLER
#include <cstdlib>
STXXL_BEGIN_NAMESPACE
int register_exit_handler(void (* function)(void))
{
return atexit(function);
}
void run_exit_handlers()
{
}
STXXL_END_NAMESPACE
#else
#include <vector>
#include <stxxl/bits/common/mutex.h>
STXXL_BEGIN_NAMESPACE
mutex exit_handler_mutex;
std::vector<void (*)(void)> exit_handlers;
int register_exit_handler(void (* function)(void))
{
scoped_mutex_lock lock(exit_handler_mutex);
exit_handlers.push_back(function);
return 0;
}
void run_exit_handlers()
{
scoped_mutex_lock lock(exit_handler_mutex);
while (!exit_handlers.empty()) {
(*(exit_handlers.back()))();
exit_handlers.pop_back();
}
}
STXXL_END_NAMESPACE
#endif
#endif