]> git.sesse.net Git - cubemap/blobdiff - udpinput.cpp
Use C++11 std::mutex and std::lock_guard instead of our RAII wrapper.
[cubemap] / udpinput.cpp
index 93eaaa76801c0dbab7383e2e7b8902b5fd408ea0..0035640ad4a91bd6ed2d4d59f3a6db8feb677a6d 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;
 }