ftpiiu_plugin/src/utils/BackgroundThreadWrapper.hpp

32 lines
653 B
C++
Raw Normal View History

2019-11-24 14:20:08 +01:00
#pragma once
#include "CThread.h"
#include <wut_types.h>
#include <mutex>
2019-11-24 14:20:08 +01:00
class BackgroundThreadWrapper: public CThread {
public:
2020-11-26 23:32:44 +01:00
explicit BackgroundThreadWrapper(int32_t priority);
~BackgroundThreadWrapper() override;
2019-11-24 14:20:08 +01:00
protected:
2020-11-26 23:32:44 +01:00
[[nodiscard]] BOOL shouldExit() const {
2019-11-24 14:20:08 +01:00
return (exitThread == 1);
}
2020-11-26 23:32:44 +01:00
void setThreadPriority(int32_t priority) override {
CThread::setThreadPriority(priority);
2019-11-24 14:20:08 +01:00
}
std::recursive_mutex mutex;
2019-11-24 14:20:08 +01:00
private:
2020-11-26 23:32:44 +01:00
void executeThread() override;
2019-11-24 14:20:08 +01:00
/**
Called when a connection has be accepted.
**/
virtual BOOL whileLoop() = 0;
volatile int32_t exitThread = 0;
};