diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-02-01 20:49:19 -0500 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-02-03 11:43:51 +0100 |
commit | 1c73902005bb5c7a40be5571bff9c232d8c69536 (patch) | |
tree | c666e23d4411c58701a4b01963e9d965234db60c /src/clientiface.h | |
parent | d387e9b6d39d9689b79da21fa263c93d2b26e840 (diff) | |
download | minetest-1c73902005bb5c7a40be5571bff9c232d8c69536.tar.xz |
Clean up ClientInterface locking
Diffstat (limited to 'src/clientiface.h')
-rw-r--r-- | src/clientiface.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/clientiface.h b/src/clientiface.h index b1591ddb0..1be9c972a 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -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 @@ public: 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; } |