31 singletons_manager::singletons_manager() : lst() {}
33 singletons_manager& singletons_manager::m = manager();
35 singletons_manager& singletons_manager::manager()
37 static singletons_manager x;
42 void singletons_manager::register_new_singleton(singleton_instance_base *p)
44 manager().lst.thrd_cast().push_back(p);
47 void singletons_manager::register_new_singleton(singleton_instance_base *p,
size_t ithread)
49 manager().lst(ithread).push_back(p);
53 static int level_compare(singleton_instance_base *a,
54 singleton_instance_base *b)
56 return a->level() < b->level();
59 singletons_manager::~singletons_manager() {
60 GMM_ASSERT1(!getfem::me_is_multithreaded_now(),
61 "singletons_manager destructor should" 62 "not be running in parallel !!");
64 for(
size_t i=0;i<getfem::num_threads();i++)
68 std::sort(lst(i).begin(),lst(i).end(), level_compare);
69 std::vector<singleton_instance_base *>::const_iterator it = lst(i).begin();
70 std::vector<singleton_instance_base *>::const_iterator ite = lst(i).end();
71 for ( ; it != ite; ++it) {
delete *it; }
Tools for multithreaded, OpenMP and Boost based parallelization.
A simple singleton implementation.
Include common gmm files.