Do not try to use ThreadIdManager after exit.
This commit is contained in:
parent
52653d6bf1
commit
4b687582c1
@ -7,6 +7,7 @@
|
|||||||
#include "td/utils/port/detail/ThreadIdGuard.h"
|
#include "td/utils/port/detail/ThreadIdGuard.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/ExitGuard.h"
|
||||||
#include "td/utils/port/thread_local.h"
|
#include "td/utils/port/thread_local.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -27,6 +28,9 @@ class ThreadIdManager {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void unregister_thread(int32 thread_id) {
|
void unregister_thread(int32 thread_id) {
|
||||||
|
if (ExitGuard::is_exited()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::lock_guard<std::mutex> guard(mutex_);
|
std::lock_guard<std::mutex> guard(mutex_);
|
||||||
CHECK(0 < thread_id && thread_id <= max_thread_id_);
|
CHECK(0 < thread_id && thread_id <= max_thread_id_);
|
||||||
bool is_inserted = unused_thread_ids_.insert(thread_id).second;
|
bool is_inserted = unused_thread_ids_.insert(thread_id).second;
|
||||||
@ -39,6 +43,7 @@ class ThreadIdManager {
|
|||||||
int32 max_thread_id_ = 0;
|
int32 max_thread_id_ = 0;
|
||||||
};
|
};
|
||||||
static ThreadIdManager thread_id_manager;
|
static ThreadIdManager thread_id_manager;
|
||||||
|
static ExitGuard exit_guard;
|
||||||
|
|
||||||
ThreadIdGuard::ThreadIdGuard() {
|
ThreadIdGuard::ThreadIdGuard() {
|
||||||
thread_id_ = thread_id_manager.register_thread();
|
thread_id_ = thread_id_manager.register_thread();
|
||||||
|
Loading…
Reference in New Issue
Block a user