]> git.sesse.net Git - cubemap/blobdiff - stream.cpp
Use C++11 std::mutex and std::lock_guard instead of our RAII wrapper.
[cubemap] / stream.cpp
index d7a78a602098ab5d77dda08873af8c3d7b29e11b..3a4ccc3ed88065a87738796e00e0b0cda627fb55 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "log.h"
 #include "metacube2.h"
 
 #include "log.h"
 #include "metacube2.h"
-#include "mutexlock.h"
 #include "state.pb.h"
 #include "stream.h"
 #include "util.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);
        }
        if (data_fd == -1) {
                exit(1);
        }
-
-       pthread_mutex_init(&queued_data_mutex, nullptr);
 }
 
 Stream::~Stream()
 }
 
 Stream::~Stream()
@@ -65,8 +62,6 @@ Stream::Stream(const StreamProto &serialized, int data_fd)
                }
                suitable_starting_points.push_back(point);
        }
                }
                suitable_starting_points.push_back(point);
        }
-
-       pthread_mutex_init(&queued_data_mutex, nullptr);
 }
 
 StreamProto Stream::serialize()
 }
 
 StreamProto Stream::serialize()
@@ -232,7 +227,7 @@ void Stream::add_data_deferred(const char *data, size_t bytes, uint16_t metacube
                return;
        }
 
                return;
        }
 
-       MutexLock lock(&queued_data_mutex);
+       lock_guard<mutex> lock(queued_data_mutex);
 
        DataElement data_element;
        data_element.metacube_flags = metacube_flags;
 
        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.
        {
        // 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;
                }
                if (queued_data.empty()) {
                        return;
                }