Go to the documentation of this file.
72 #pragma warning(disable: 4127)
136 bool isAlive(
void)
volatile const noexcept;
137 bool isRunning(
void)
volatile const noexcept;
151 void terminateThread();
154 #define XSENS_THREAD_CHECK() if (isTerminating()) return 0
159 #define CDECL_XS __cdecl
191 bool isAlive(
void)
volatile const noexcept;
192 bool isRunning(
void)
volatile const noexcept;
328 #pragma warning(default: 4127)
A class that will run a single (lambda) function in a separate thread.
virtual ~StandardThread()
std::deque< TaskType > m_queue
static XSENS_THREAD_RETURN threadInit(void *obj)
static void threadCleanup(void *obj)
Cleanup the thread by calling the exit function.
void addTask(TaskFunction func, void *param)
Adds a task to a queue.
bool isRunning(void) volatile const noexcept
Returns whether the thread is currently running.
pthread_attr_t m_attr
Duplicates m_stop functionality for external dependent classes such as Semaphore.
bool stopTimer(void) noexcept
Stops the timer.
bool resetTimer(uint32_t timeout=0)
Resets the timer and sets a timeout.
XsThreadId getThreadId(void) const
virtual int32_t innerFunction(void)
Virtual inner function.
bool startThread(const char *name=NULL)
Starts the thread.
volatile std::atomic_bool m_yieldOnZeroSleep
When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation....
WatchDogThread(WatchDogFunction func, void *param=NULL)
Constructor.
ThreadedFunction(std::function< void()> const &f, bool runNow=true)
Construct the object.
pthread_t XsThread
A handle for a thread.
int32_t getLength(void) noexcept
void clear(void)
Clears a queue.
~WatchDogThread()
Destructor.
Class for handling small tasks.
virtual void exitFunction(void)
Virtual exit function.
bool isTerminating() volatile const noexcept
Returns whether the thread should (have) terminate(d)
virtual void signalStopThread(void)
Tells the thread to stop but does not wait for it to end.
XsThread threadHandle() const
Return the thread handle.
bool m_running
Indicates that the thread is running.
boost::function< void(DiagnosticStatusWrapper &)> TaskFunction
bool isAlive(void) volatile const noexcept
#define XSENS_THREAD_RETURN
int32_t innerFunction(void) override final
The internal thread function, runs the supplied function.
void threadMain(void)
The inner loop of the thread, calls innerFunction repeatedly and sleeps when necessary.
bool unlock() noexcept
Unlocks the locked mutex.
bool isRunning(void) volatile const noexcept
bool startTimer(uint32_t timeout=10000, const char *name=NULL)
Starts a timer using some parameters.
A class for a standard thread that has to perform the same action repeatedly.
XsThreadPriority
Thread priorities for xsSetThreadPriority() and xsGetThreadPriority()
void stopThread(void) noexcept
Tells the thread to stop and waits for it to end.
A class that keeps an eye on a threads timer.
T param(const std::string ¶m_name, const T &default_val)
volatile std::atomic_bool m_stop
Indicates that the thread should stop. Derived classes should check isTerminating() instead of direct...
static XSENS_THREAD_RETURN threadInit(void *obj)
bool isAlive(void) volatile const noexcept
virtual void initFunction(void)
Virtual initialization function.
virtual int32_t innerFunction(void)
The inner function of the task thread.
XsThreadId getThreadId(void) const
bool setPriority(XsThreadPriority pri)
Sets the priority of the thread.
void(CDECL_XS * WatchDogFunction)(void *)
std::function< void()> m_func
XsThreadPriority m_priority
volatile std::atomic< std::uint32_t > m_timeout