Use C++11 std::mutex and std::lock_guard instead of our RAII wrapper.
[cubemap] / udpinput.cpp
index 93eaaa7..0035640 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "acceptor.h"
 #include "log.h"
-#include "mutexlock.h"
 #include "serverpool.h"
 #include "state.pb.h"
 #include "stream.h"
@@ -113,7 +112,6 @@ UDPInput::UDPInput(const string &url)
 
        construct_header();
 
-       pthread_mutex_init(&stats_mutex, nullptr);
        stats.url = url;
        stats.connect_time = time(nullptr);
 }
@@ -129,7 +127,6 @@ UDPInput::UDPInput(const InputProto &serialized)
 
        construct_header();
 
-       pthread_mutex_init(&stats_mutex, nullptr);
        stats.url = url;
        stats.bytes_received = serialized.bytes_received();
        stats.data_bytes_received = serialized.data_bytes_received();
@@ -220,7 +217,7 @@ void UDPInput::do_work()
                }
 
                {
-                       MutexLock lock(&stats_mutex);
+                       lock_guard<mutex> lock(stats_mutex);
                        stats.bytes_received += ret;
                        stats.data_bytes_received += ret;
                }
@@ -233,6 +230,6 @@ void UDPInput::do_work()
 
 InputStats UDPInput::get_stats() const
 {
-       MutexLock lock(&stats_mutex);
+       lock_guard<mutex> lock(stats_mutex);
        return stats;
 }