- attempt to have more clean shutdown of threads on game exit

This commit is contained in:
Mark Vejvoda
2013-05-17 00:08:26 +00:00
parent 4bc007f239
commit 910bb8bc56
7 changed files with 196 additions and 23 deletions

View File

@@ -91,10 +91,14 @@ public:
Mutex * getMutexThreadObjectAccessor() { return &mutexThreadObjectAccessor; }
template <typename T>
T * getGenericData() { return genericData; }
template <typename T>
void setGenericData(T *value) { genericData = value; }
template <typename T>
T * getGenericData() {
return genericData;
}
template <typename T>
void setGenericData(T *value) {
genericData = value;
}
static bool isThreadDeleted(void *ptr);
};

View File

@@ -58,21 +58,30 @@ public:
private:
SDL_Thread* thread;
bool deleteAfterExecute;
static Mutex mutexthreadList;
static vector<Thread *> threadList;
protected:
void addThreadToList();
void removeThreadFromList();
public:
Thread();
virtual ~Thread();
static std::vector<Thread *> getThreadList();
static void shutdownThreads();
void setDeleteAfterExecute(bool value) { deleteAfterExecute = value; }
bool getDeleteAfterExecute() const { return deleteAfterExecute; }
void start();
virtual void execute()=0;
void setPriority(Thread::Priority threadPriority);
void suspend();
void resume();
void kill();
private:
static int beginExecution(void *param);