Expose getPointedThing to Lua
[oweals/minetest.git] / src / util / thread.h
index 8d8b6fe7f80fbad8e93044b3a36fb5c7c39aef2d..201d09a08c1110249dd2fbb389f704e843c07916 100644 (file)
@@ -22,15 +22,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "../irrlichttypes.h"
 #include "../threading/thread.h"
-#include "../threading/mutex.h"
 #include "../threading/mutex_auto_lock.h"
 #include "porting.h"
 #include "log.h"
+#include "container.h"
 
 template<typename T>
-class MutexedVariable {
+class MutexedVariable
+{
 public:
-       MutexedVariable(value):
+       MutexedVariable(const T &value):
                m_value(value)
        {}
 
@@ -40,23 +41,16 @@ public:
                return m_value;
        }
 
-       void set(value)
+       void set(const T &value)
        {
                MutexAutoLock lock(m_mutex);
                m_value = value;
        }
 
-       // You'll want to grab this in a SharedPtr
-       MutexAutoLock *getLock()
-       {
-               return new MutexAutoLock(m_mutex);
-       }
-
        // You pretty surely want to grab the lock when accessing this
        T m_value;
-
 private:
-       Mutex m_mutex;
+       std::mutex m_mutex;
 };
 
 /*
@@ -88,8 +82,8 @@ public:
        GetRequest() {}
        ~GetRequest() {}
 
-       GetRequest(Key a_key) {
-               key = a_key;
+       GetRequest(const Key &a_key): key(a_key)
+       {
        }
 
        Key key;
@@ -111,7 +105,7 @@ public:
                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;
@@ -210,7 +204,7 @@ public:
 
        void *run()
        {
-               DSTACK(__FUNCTION_NAME);
+               DSTACK(FUNCTION_NAME);
                BEGIN_DEBUG_EXCEPTION_HANDLER
 
                while (!stopRequested()) {