Add option to name threads and name main thread
This commit is contained in:
27
openVulkanoCpp/Base/Utils.cpp
Normal file
27
openVulkanoCpp/Base/Utils.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Utils.hpp"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace openVulkanoCpp
|
||||||
|
{
|
||||||
|
void Utils::SetThreadName(const std::string& name)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
auto thisThread = ::GetCurrentThread();
|
||||||
|
std::wstring namew(name.begin(), name.end());
|
||||||
|
SetThreadDescription(thisThread, namew.c_str());
|
||||||
|
#else
|
||||||
|
pthread_setname_np(pthread_self(), name.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ namespace openVulkanoCpp
|
|||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static void SetThreadName(const std::string& name);
|
||||||
|
|
||||||
static inline std::vector<const char*> toCString(const std::vector<std::string>& values)
|
static inline std::vector<const char*> toCString(const std::vector<std::string>& values)
|
||||||
{
|
{
|
||||||
std::vector<const char*> result;
|
std::vector<const char*> result;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace openVulkanoCpp
|
|||||||
GraphicsAppManager::GraphicsAppManager(openVulkanoCpp::IGraphicsApp* app, RenderAPI::RenderApi renderApi)
|
GraphicsAppManager::GraphicsAppManager(openVulkanoCpp::IGraphicsApp* app, RenderAPI::RenderApi renderApi)
|
||||||
: app(app), renderApi(renderApi)
|
: app(app), renderApi(renderApi)
|
||||||
{
|
{
|
||||||
|
Utils::SetThreadName("Main");
|
||||||
Logger::SetupLogger();
|
Logger::SetupLogger();
|
||||||
if (!app)
|
if (!app)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user