Thread: Add name parameter
For debugging purposes, threads can be assigned a name, which eases distinguishing between them in e.g. htop or gdb. This uses a Linux-specific API for now which is limited to 15 characters (+ null terminator), so truncation is done and names for existing thread instantiations were chosen to be consise. [Kieran: Apply checkstyle suggestions, rebase on proxy rework] Signed-off-by: Schulz, Andreas <andreas.schulz2@karlstorz.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
6af90deaf2
commit
559128b1f1
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user