src/thread/windows/SDL_sysmutex.c
changeset 6966 090df160f6e0
parent 6885 700f1b25f77f
child 6969 74cf567e8618
--- a/src/thread/windows/SDL_sysmutex.c	Tue Mar 05 18:01:59 2013 -0500
+++ b/src/thread/windows/SDL_sysmutex.c	Tue Mar 05 18:54:55 2013 -0500
@@ -75,6 +75,22 @@
     return (0);
 }
 
+/* TryLock the mutex */
+int
+SDL_TryLockMutex(SDL_mutex * mutex)
+{
+    if (mutex == NULL) {
+        SDL_SetError("Passed a NULL mutex");
+        return -1;
+    }
+
+    int retval = 0;
+    if (TryEnterCriticalSection(&mutex->cs) == 0) {
+        retval = SDL_MUTEX_TIMEDOUT;
+    }
+    return retval;
+}
+
 /* Unlock the mutex */
 int
 SDL_mutexV(SDL_mutex * mutex)