Use C++11 std::mutex and std::lock_guard instead of our RAII wrapper.
[cubemap] / stream.cpp
index d7a78a6..3a4ccc3 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "log.h"
 #include "metacube2.h"
-#include "mutexlock.h"
 #include "state.pb.h"
 #include "stream.h"
 #include "util.h"
@@ -31,8 +30,6 @@ Stream::Stream(const string &url, size_t backlog_size, size_t prebuffering_bytes
        if (data_fd == -1) {
                exit(1);
        }
-
-       pthread_mutex_init(&queued_data_mutex, nullptr);
 }
 
 Stream::~Stream()
@@ -65,8 +62,6 @@ Stream::Stream(const StreamProto &serialized, int data_fd)
                }
                suitable_starting_points.push_back(point);
        }
-
-       pthread_mutex_init(&queued_data_mutex, nullptr);
 }
 
 StreamProto Stream::serialize()
@@ -232,7 +227,7 @@ void Stream::add_data_deferred(const char *data, size_t bytes, uint16_t metacube
                return;
        }
 
-       MutexLock lock(&queued_data_mutex);
+       lock_guard<mutex> lock(queued_data_mutex);
 
        DataElement data_element;
        data_element.metacube_flags = metacube_flags;
@@ -271,7 +266,7 @@ void Stream::process_queued_data()
        // Hold the lock for as short as possible, since add_data_raw() can possibly
        // write to disk, which might disturb the input thread.
        {
-               MutexLock lock(&queued_data_mutex);
+               lock_guard<mutex> lock(queued_data_mutex);
                if (queued_data.empty()) {
                        return;
                }