Add support for IPv6
[oweals/minetest.git] / src / jthread / jmutex.h
index 6675162a56b6070efdc22e3b021f5c20aa6d3f94..8efdc7bc58cff3d103a7b0df66fe53538e95da70 100644 (file)
@@ -30,6 +30,9 @@
 #define JMUTEX_H
 
 #if (defined(WIN32) || defined(_WIN32_WCE))
+       #ifndef _WIN32_WINNT
+               #define _WIN32_WINNT 0x0501
+       #endif
        #ifndef _WIN32_WCE
                #include <process.h>
        #endif // _WIN32_WCE
@@ -54,6 +57,7 @@ public:
        int Lock();
        int Unlock();
        bool IsInitialized()                                            { return initialized; }
+
 private:
 #if (defined(WIN32) || defined(_WIN32_WCE))
 #ifdef JMUTEX_CRITICALSECTION
@@ -63,6 +67,14 @@ private:
 #endif // JMUTEX_CRITICALSECTION
 #else // pthread mutex
        pthread_mutex_t mutex;
+
+       bool IsLocked() {
+               if (pthread_mutex_trylock(&mutex)) {
+                       pthread_mutex_unlock(&mutex);
+                       return true;
+               }
+               return false;
+       }
 #endif // WIN32
        bool initialized;
 };
@@ -88,7 +100,7 @@ public:
        void signal() {
                SetEvent(hEvent);
        }
-}
+};
 
 #else