The-Powder-Toy/src/tasks/Task.h

49 lines
789 B
C
Raw Normal View History

/*
* 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();
2012-06-20 11:51:51 -05:00
void Poll();
Task() {}
virtual ~Task();
protected:
int progress;
bool done;
std::string status;
2012-06-20 11:51:51 -05:00
int thProgress;
bool thDone;
std::string thStatus;
TaskListener * listener;
pthread_t doWorkThread;
2012-06-20 11:51:51 -05:00
pthread_mutex_t taskMutex;
pthread_cond_t taskCond;
virtual void doWork();
static void * doWork_helper(void * ref);
2012-06-20 11:51:51 -05:00
void notifyProgress(int progress);
void notifyStatus(std::string status);
void notifyDone();
};
#endif /* TASK_H_ */