Add names to threads (#3729)

This is useful for Sentry crash reports, so we can identify threads by
name.
This commit is contained in:
David Capello 2023-08-29 13:55:40 -03:00
parent 6c5b27db81
commit f4aa19ad8c
9 changed files with 25 additions and 5 deletions

2
laf

@ -1 +1 @@
Subproject commit 78478475e56c48b5290907d3a66db91d309f9e8a
Subproject commit 076a52afca497866eb5862b928d4db39783abe59

View File

@ -18,6 +18,7 @@
#include "base/convert_to.h"
#include "base/launcher.h"
#include "base/replace_string.h"
#include "base/thread.h"
#include "base/version.h"
#include "ver/info.h"
@ -198,6 +199,8 @@ void CheckUpdateThreadLauncher::onMonitoringTick()
// This method is executed in a special thread to send the HTTP request.
void CheckUpdateThreadLauncher::checkForUpdates()
{
base::this_thread::set_name("check-update");
// Add mini-stats in the request
std::stringstream extraParams;
extraParams << "inits=" << m_inits

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -11,6 +11,7 @@
#include "app/closed_docs.h"
#include "app/doc.h"
#include "app/pref/preferences.h"
#include "base/thread.h"
#include <algorithm>
#include <limits>
@ -118,6 +119,8 @@ void ClosedDocs::backgroundThread()
{
CLOSEDOC_TRACE("CLOSEDOC: [BG] Background thread start");
base::this_thread::set_name("closed-docs");
std::unique_lock<std::mutex> lock(m_mutex);
while (!m_done) {
base::tick_t now = base::current_tick();

View File

@ -29,6 +29,7 @@
#include "app/pref/preferences.h"
#include "base/chrono.h"
#include "base/remove_from_container.h"
#include "base/thread.h"
#include "ui/system.h"
namespace app {
@ -123,6 +124,7 @@ void BackupObserver::onRemoveDocument(Doc* doc)
void BackupObserver::backgroundThread()
{
std::unique_lock<std::mutex> lock(m_mutex);
base::this_thread::set_name("backup");
int normalPeriod = int(60.0*m_config->dataRecoveryPeriod);
int lockedPeriod = 5;

View File

@ -17,6 +17,7 @@
#include "app/pref/preferences.h"
#include "app/resource_finder.h"
#include "base/fs.h"
#include "base/thread.h"
#include "base/time.h"
#include "ui/system.h"
@ -109,6 +110,7 @@ void DataRecovery::launchSearch()
m_thread = std::thread(
[this]{
base::this_thread::set_name("search-sessions");
searchForSessions();
m_searching = false;
});

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -206,6 +206,8 @@ private:
}
void loadBgThread() {
base::this_thread::set_name("thumbnails");
while (!m_queue.empty()) {
bool success = true;
while (success) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
@ -176,6 +176,8 @@ private:
void paintingProc() {
COLSEL_TRACE("COLSEL: paintingProc starts\n");
base::this_thread::set_name("colsel-painter");
std::unique_lock<std::mutex> lock(m_mutex);
while (true) {
m_paintingCV.wait(lock);

View File

@ -12,6 +12,7 @@
#include "app/i18n/strings.h"
#include "app/resource_finder.h"
#include "base/fs.h"
#include "base/thread.h"
#include "enter_license.h"
#include "ui/message.h"
#include "ui/style.h"
@ -72,6 +73,7 @@ void EnterLicense::startActivation()
std::string key = licenseKey()->text();
m_activationInProgress = true;
m_activation = std::thread([this, key]() {
base::this_thread::set_name("activate-key");
try {
auto token = drm::LicenseManager::instance()->activate(key);
onActivated(token);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -17,6 +17,7 @@
#include "base/exception.h"
#include "base/memory.h"
#include "base/system_console.h"
#include "base/thread.h"
#include "doc/palette.h"
#include "os/error.h"
#include "os/system.h"
@ -112,6 +113,9 @@ int app_main(int argc, char* argv[])
CoInit com; // To create COM objects
#endif
// Main thread name
base::this_thread::set_name("main");
try {
#if ENABLE_SENTRY
app::Sentry sentry;