]> git.lizzy.rs Git - minetest.git/blobdiff - src/util/thread.h
Initialize wield mesh colors when changing item. (#12254)
[minetest.git] / src / util / thread.h
index f54b8b48f25dfcbfa91002364d17d70bd77d00bb..73e9beb806f44d8effc6dd8e3a3bec3f82adf23f 100644 (file)
@@ -17,13 +17,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef UTIL_THREAD_HEADER
-#define UTIL_THREAD_HEADER
+#pragma once
 
-#include "../irrlichttypes.h"
-#include "../threading/thread.h"
-#include "../threading/mutex.h"
-#include "../threading/mutex_auto_lock.h"
+#include "irrlichttypes.h"
+#include "threading/thread.h"
+#include "threading/mutex_auto_lock.h"
 #include "porting.h"
 #include "log.h"
 #include "container.h"
@@ -51,7 +49,7 @@ class MutexedVariable
        // You pretty surely want to grab the lock when accessing this
        T m_value;
 private:
-       Mutex m_mutex;
+       std::mutex m_mutex;
 };
 
 /*
@@ -80,11 +78,11 @@ class CallerInfo {
 template<typename Key, typename T, typename Caller, typename CallerData>
 class GetRequest {
 public:
-       GetRequest() {}
-       ~GetRequest() {}
+       GetRequest() = default;
+       ~GetRequest() = default;
 
-       GetRequest(Key a_key) {
-               key = a_key;
+       GetRequest(const Key &a_key): key(a_key)
+       {
        }
 
        Key key;
@@ -106,7 +104,7 @@ class RequestQueue {
                return m_queue.empty();
        }
 
-       void add(Key key, Caller caller, CallerData callerdata,
+       void add(const Key &key, Caller caller, CallerData callerdata,
                ResultQueue<Key, T, Caller, CallerData> *dest)
        {
                typename std::deque<GetRequest<Key, T, Caller, CallerData> >::iterator i;
@@ -191,7 +189,7 @@ class UpdateThread : public Thread
 {
 public:
        UpdateThread(const std::string &name) : Thread(name + "Update") {}
-       ~UpdateThread() {}
+       ~UpdateThread() = default;
 
        void deferUpdate() { m_update_sem.post(); }
 
@@ -205,7 +203,6 @@ class UpdateThread : public Thread
 
        void *run()
        {
-               DSTACK(FUNCTION_NAME);
                BEGIN_DEBUG_EXCEPTION_HANDLER
 
                while (!stopRequested()) {
@@ -229,6 +226,3 @@ class UpdateThread : public Thread
 private:
        Semaphore m_update_sem;
 };
-
-#endif
-