You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
548 B
C

#ifndef _CTHREAD_H_
#define _CTHREAD_H_
#include <QThread>
#include <QMutex>
#include <functional>
typedef std::function<void(void)> TaskFunc;
class CThread : public QThread
{
Q_OBJECT
public:
CThread(QObject *parent = 0);
~CThread();
void startProcess();
void setTaskFunc(TaskFunc func) {
m_func = func;
}
void setSleepms(int m_time = 1)
{
m_sleepms = m_time;
}
public slots:
void stopProcess();
protected:
void run();
private:
bool m_abort;
QMutex mutex;
int m_sleepms{ 10 };
TaskFunc m_func;
};
#endif // ! _CTHREAD_H_