Use C++11 std::mutex and std::lock_guard instead of our RAII wrapper.
[cubemap] / thread.cpp
index 473c71a..d85be70 100644 (file)
@@ -7,14 +7,14 @@
 #include <unistd.h>
 
 #include "log.h"
-#include "mutexlock.h"
 #include "thread.h"
 
+using namespace std;
+
 Thread::~Thread() {}
 
 void Thread::run()
 {
-       pthread_mutex_init(&should_stop_mutex, nullptr);
        should_stop_status = false;
        pthread_create(&worker_thread, nullptr, &Thread::do_work_thunk, this);
 }
@@ -22,7 +22,7 @@ void Thread::run()
 void Thread::stop()
 {
        {
-               MutexLock lock(&should_stop_mutex);
+               lock_guard<mutex> lock(should_stop_mutex);
                should_stop_status = true;
        }
        wakeup();
@@ -92,6 +92,6 @@ void Thread::wakeup()
 
 bool Thread::should_stop()
 {
-       MutexLock lock(&should_stop_mutex);
+       lock_guard<mutex> lock(should_stop_mutex);
        return should_stop_status;
 }