Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions libkineto/src/ConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ void ConfigLoader::startThread() {
}
}

void ConfigLoader::signalStop() {
stopFlag_ = true;
{
std::lock_guard<std::mutex> lock(updateThreadMutex_);
updateThreadCondVar_.notify_one();
}
}

void ConfigLoader::stopThread() {
signalStop();
if (updateThread_) {
stopFlag_ = true;
{
std::lock_guard<std::mutex> lock(updateThreadMutex_);
updateThreadCondVar_.notify_one();
}
if (updateThread_->joinable()) {
updateThread_->join();
}
Expand Down
9 changes: 7 additions & 2 deletions libkineto/src/ConfigLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ class ConfigLoader {

std::string getConfString();

// Stop the background polling thread. Safe to call multiple times.
// Exposed for embedders that need to join the thread before other
// Signal the background polling thread to stop without joining it.
// Use this when joining is unsafe (e.g., the thread may be blocked on a
// lock held by the caller). The thread will exit on its next loop iteration.
void signalStop();

// Stop the background polling thread and join it. Safe to call multiple
// times. Exposed for embedders that need to join the thread before other
// singletons are destroyed.
void stopThread();

Expand Down
Loading