]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/clientiface.h
Clean up ClientInterface locking
[dragonfireclient.git] / src / clientiface.h
index b1591ddb027332181be646e3ca0a90e8478ba03b..1be9c972a5218be3657d0f3573d1fa740a132a83 100644 (file)
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "network/networkprotocol.h"
 #include "network/address.h"
 #include "porting.h"
+#include "threading/mutex_auto_lock.h"
 
 #include <list>
 #include <vector>
@@ -503,9 +504,13 @@ class ClientInterface {
 
        static std::string state2Name(ClientState state);
 protected:
-       //TODO find way to avoid this functions
-       void lock() { m_clients_mutex.lock(); }
-       void unlock() { m_clients_mutex.unlock(); }
+       class AutoLock {
+       public:
+               AutoLock(ClientInterface &iface): m_lock(iface.m_clients_mutex) {}
+
+       private:
+               RecursiveMutexAutoLock m_lock;
+       };
 
        RemoteClientMap& getClientList() { return m_clients; }