Do not try to use ThreadIdManager after exit.

This commit is contained in:
levlam 2020-11-23 00:38:16 +03:00
parent 52653d6bf1
commit 4b687582c1

View File

@ -7,6 +7,7 @@
#include "td/utils/port/detail/ThreadIdGuard.h"
#include "td/utils/common.h"
#include "td/utils/ExitGuard.h"
#include "td/utils/port/thread_local.h"
#include <mutex>
@ -27,6 +28,9 @@ class ThreadIdManager {
return result;
}
void unregister_thread(int32 thread_id) {
if (ExitGuard::is_exited()) {
return;
}
std::lock_guard<std::mutex> guard(mutex_);
CHECK(0 < thread_id && thread_id <= max_thread_id_);
bool is_inserted = unused_thread_ids_.insert(thread_id).second;
@ -39,6 +43,7 @@ class ThreadIdManager {
int32 max_thread_id_ = 0;
};
static ThreadIdManager thread_id_manager;
static ExitGuard exit_guard;
ThreadIdGuard::ThreadIdGuard() {
thread_id_ = thread_id_manager.register_thread();