@@ -8,6 +8,7 @@
#pragma once
#include <memory>
+#include <string>
#include <sys/types.h>
#include <thread>
@@ -30,7 +31,7 @@ class ThreadMain;
class Thread
{
public:
- Thread();
+ Thread(std::string name = {});
virtual ~Thread();
void start();
@@ -74,6 +75,7 @@ private:
void moveObject(Object *object, ThreadData *currentData,
ThreadData *targetData);
+ std::string name_;
std::thread thread_;
std::unique_ptr<ThreadData> data_;
};
@@ -10,6 +10,7 @@
#include <atomic>
#include <list>
#include <optional>
+#include <pthread.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
@@ -144,6 +145,7 @@ class ThreadMain : public Thread
{
public:
ThreadMain()
+ : Thread("libcamera-main")
{
data_->running_ = true;
}
@@ -234,8 +236,9 @@ ThreadData *ThreadData::current()
/**
* \brief Create a thread
*/
-Thread::Thread()
- : data_(std::make_unique<ThreadData>(this))
+Thread::Thread(std::string name)
+ : name_(std::move(name)),
+ data_(std::make_unique<ThreadData>(this))
{
}
@@ -288,6 +291,10 @@ void Thread::startThread()
data_->tid_ = syscall(SYS_gettid);
currentThreadData = data_.get();
+ if (!name_.empty())
+ pthread_setname_np(thread_.native_handle(),
+ name_.substr(0, 15).c_str());
+
run();
}
@@ -39,7 +39,7 @@ LOG_DEFINE_CATEGORY(Camera)
#ifndef __DOXYGEN_PUBLIC__
CameraManager::Private::Private()
- : initialized_(false)
+ : Thread("CameraManager"), initialized_(false)
{
ipaManager_ = std::make_unique<IPAManager>(this->configuration());
}
@@ -115,7 +115,7 @@ private:
VirtualCameraData::VirtualCameraData(PipelineHandler *pipe,
const std::vector<Resolution> &supportedResolutions)
- : Camera::Private(pipe)
+ : Camera::Private(pipe), Thread("VirtualCamera")
{
config_.resolutions = supportedResolutions;
for (const auto &resolution : config_.resolutions) {
@@ -75,7 +75,8 @@ LOG_DEFINE_CATEGORY(SoftwareIsp)
*/
SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
ControlInfoMap *ipaControls)
- : dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |
+ : ispWorkerThread_("SWIspWorker"),
+ dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |
DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |
DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)
{
@@ -46,7 +46,7 @@ namespace {{ns}} {
{%- endif %}
{{proxy_name}}Threaded::{{proxy_name}}Threaded(IPAModule *ipam, const GlobalConfiguration &configuration)
- : {{proxy_name}}(ipam, configuration)
+ : {{proxy_name}}(ipam, configuration), thread_("{{proxy_name}}")
{
LOG(IPAProxy, Debug)
<< "initializing {{module_name}} proxy in thread: loading IPA from "