Skip to content

Commit

Permalink
fix: remove dtor tcache error
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Life committed Nov 26, 2024
1 parent 8f05cf0 commit 3eb3752
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class DPP_EXPORT cluster {
* @brief Used to spawn the socket engine into its own thread if
* the cluster is started with dpp::st_return. It is unused otherwise.
*/
std::unique_ptr<std::thread> engine_thread{nullptr};
std::thread engine_thread;

/**
* @brief Protection mutex for timers
Expand Down
14 changes: 7 additions & 7 deletions src/dpp/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void cluster::start(bool return_after) {
});

if (return_after) {
engine_thread = std::make_unique<std::thread>([event_loop]() {
engine_thread = std::thread([event_loop]() {
dpp::utility::set_thread_name("event_loop");
event_loop();
});
Expand All @@ -310,13 +310,12 @@ void cluster::start(bool return_after) {
void cluster::shutdown() {
/* Signal termination */
terminating = true;
if (engine_thread) {
if (engine_thread->joinable()) {
engine_thread->join();
} else {
log(ll_warning, "Cluster engine_thread is not joinable on dtor");
}

if (engine_thread.joinable()) {
/* Join engine_thread if it ever started */
engine_thread.join();
}

{
std::lock_guard<std::mutex> l(timer_guard);
/* Free memory for active timers */
Expand All @@ -326,6 +325,7 @@ void cluster::shutdown() {
timer_list.clear();
next_timer.clear();
}

/* Terminate shards */
for (const auto& sh : shards) {
delete sh.second;
Expand Down

0 comments on commit 3eb3752

Please sign in to comment.