blob: d5ccd4b92ae8b5f8142049a1810608dbd642d7f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Task.h
*
* Created on: Apr 6, 2012
* Author: Simon
*/
#ifndef TASK_H_
#define TASK_H_
#include <string>
#include <pthread.h>
#include "TaskListener.h"
class TaskListener;
class Task {
public:
void SetTaskListener(TaskListener * listener);
void Start();
int GetProgress();
bool GetDone();
std::string GetStatus();
void Poll();
Task() {}
virtual ~Task();
protected:
int progress;
bool done;
std::string status;
int thProgress;
bool thDone;
std::string thStatus;
TaskListener * listener;
pthread_t doWorkThread;
pthread_mutex_t taskMutex;
pthread_cond_t taskCond;
virtual void doWork();
static void * doWork_helper(void * ref);
void notifyProgress(int progress);
void notifyStatus(std::string status);
void notifyDone();
};
#endif /* TASK_H_ */
|