fix(util/thread,init/init): initialization problem
This commit is contained in:
parent
3c50a9cff8
commit
ade3f80089
3 changed files with 17 additions and 3 deletions
|
@ -63,5 +63,6 @@ initializer::initializer() {
|
||||||
|
|
||||||
initializer::~initializer() {
|
initializer::~initializer() {
|
||||||
finalize();
|
finalize();
|
||||||
|
delete_thread_finalizer_manager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,14 +108,24 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static thread_finalizers_manager g_aux;
|
thread_finalizers_manager * g_aux = nullptr;
|
||||||
|
|
||||||
|
thread_finalizers_manager & get_manager() {
|
||||||
|
if (!g_aux)
|
||||||
|
g_aux = new thread_finalizers_manager();
|
||||||
|
return *g_aux;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_thread_finalizer_manager() {
|
||||||
|
delete g_aux;
|
||||||
|
}
|
||||||
|
|
||||||
void register_thread_finalizer(thread_finalizer fn, void * p) {
|
void register_thread_finalizer(thread_finalizer fn, void * p) {
|
||||||
g_aux.get_thread_finalizers().emplace_back(fn, p);
|
get_manager().get_thread_finalizers().emplace_back(fn, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_post_thread_finalizer(thread_finalizer fn, void * p) {
|
void register_post_thread_finalizer(thread_finalizer fn, void * p) {
|
||||||
g_aux.get_post_thread_finalizers().emplace_back(fn, p);
|
get_manager().get_post_thread_finalizers().emplace_back(fn, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_thread_finalizers() {
|
void run_thread_finalizers() {
|
||||||
|
@ -128,6 +138,8 @@ void run_post_thread_finalizers() {
|
||||||
LEAN_THREAD_PTR(thread_finalizers, g_finalizers);
|
LEAN_THREAD_PTR(thread_finalizers, g_finalizers);
|
||||||
LEAN_THREAD_PTR(thread_finalizers, g_post_finalizers);
|
LEAN_THREAD_PTR(thread_finalizers, g_post_finalizers);
|
||||||
|
|
||||||
|
void delete_thread_finalizer_manager() {}
|
||||||
|
|
||||||
void register_thread_finalizer(thread_finalizer fn, void * p) {
|
void register_thread_finalizer(thread_finalizer fn, void * p) {
|
||||||
if (!g_finalizers)
|
if (!g_finalizers)
|
||||||
g_finalizers = new thread_finalizers();
|
g_finalizers = new thread_finalizers();
|
||||||
|
|
|
@ -207,4 +207,5 @@ void register_post_thread_finalizer(thread_finalizer fn, void * p);
|
||||||
void register_thread_finalizer(thread_finalizer fn, void * p);
|
void register_thread_finalizer(thread_finalizer fn, void * p);
|
||||||
void run_thread_finalizers();
|
void run_thread_finalizers();
|
||||||
void run_post_thread_finalizers();
|
void run_post_thread_finalizers();
|
||||||
|
void delete_thread_finalizer_manager();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue