mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-03 03:10:04 +02:00

* gui message doesnt show if it has a '>' symbol in error msg * minor refactoring for readability (size_t calc fifo size) * refactoring listening udp socket code: activated and datastream dont create udp sockets anyway, rc<=- should be discarded in any case * wip * refactoring memory structure access * wip: bugfix write header + data to binary * wip * wip * wip * wip * wip * wip * wip * wip * wip * portRoi no roi effecto on progress * fail at receiver progress, wip * segfaults for char pointer in struct * reference to header to get header and data * refactoring * use const defined for size of header of fifo * updated release notes * remove pointer in callback for sls_receiver_header pointer * rx same name arguments in constructors * rx: same name arguments in constructor * rx: removing the '_' suffix in class data members * merge fix * merge fix * review fix refactoring
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#pragma once
|
|
/************************************************
|
|
* @file ThreadObject.h
|
|
* @short creates/destroys a thread
|
|
***********************************************/
|
|
/**
|
|
*@short creates/destroys a thread
|
|
*/
|
|
|
|
#include "sls/logger.h"
|
|
#include "sls/sls_detector_defs.h"
|
|
|
|
#include <atomic>
|
|
#include <semaphore.h>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
namespace sls {
|
|
|
|
class ThreadObject : private virtual slsDetectorDefs {
|
|
protected:
|
|
const int index{0};
|
|
|
|
public:
|
|
ThreadObject(int index, std::string type);
|
|
virtual ~ThreadObject();
|
|
pid_t GetThreadId() const;
|
|
bool IsRunning() const;
|
|
void StartRunning();
|
|
void StopRunning();
|
|
void Continue();
|
|
void SetThreadPriority(int priority);
|
|
|
|
private:
|
|
virtual void ThreadExecution() = 0;
|
|
/**
|
|
* Thread called: An infinite while loop in which,
|
|
* semaphore starts executing its contents as long RunningMask is satisfied
|
|
* Then it exits the thread on its own if killThread is true
|
|
*/
|
|
void RunningThread();
|
|
|
|
std::atomic<bool> killThread{false};
|
|
std::atomic<bool> runningFlag{false};
|
|
std::thread threadObject;
|
|
sem_t semaphore;
|
|
const std::string type;
|
|
std::atomic<pid_t> threadId{0};
|
|
};
|
|
|
|
} // namespace sls
|