1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix some threading things and add additional thread unittests

- Fix thread name reset on start()
- Fully reset thread state on kill()
- Add unittests to check for correct object states under various circumstances
This commit is contained in:
kwolekr 2015-10-17 22:42:48 -04:00
parent 59fa117d13
commit 964be640cb
4 changed files with 137 additions and 55 deletions

View file

@ -81,9 +81,10 @@ public:
/*
* Waits for thread to finish.
* Note: This does not stop a thread, you have to do this on your own.
* Returns immediately if the thread is not started.
* Returns false immediately if the thread is not started or has been waited
* on before.
*/
void wait();
bool wait();
/*
* Returns true if the calling thread is this Thread object.
@ -140,15 +141,14 @@ protected:
private:
void *m_retval;
bool m_joinable;
Atomic<bool> m_request_stop;
Atomic<bool> m_running;
Mutex m_continue_mutex;
Mutex m_mutex;
threadid_t m_thread_id;
threadhandle_t m_thread_handle;
void cleanup();
static ThreadStartFunc threadProc;
#ifdef _AIX