#pragma once /************************************************ * @file ThreadObject.h * @short creates/destroys a thread ***********************************************/ /** *@short creates/destroys a thread */ #include "sls_detector_defs.h" #include "logger.h" #include #include #include #include class ThreadObject : private virtual slsDetectorDefs { public: ThreadObject(int threadIndex, std::string threadType); virtual ~ThreadObject(); virtual bool IsRunning() = 0; void Continue(); void SetThreadPriority(int priority); protected: virtual void ThreadExecution() = 0; private: /** * 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(); protected: int index{0}; std::string type; std::atomic killThread{false}; std::unique_ptr threadObject; sem_t semaphore; };