src/thread/stdcpp/SDL_sysmutex.cpp
changeset 8611 a762dfc67e1a
parent 8600 092802455aed
child 8615 097646deaef2
equal deleted inserted replaced
8608:c5d603f7094e 8611:a762dfc67e1a
    77         SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
    77         SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
    78         return -1;
    78         return -1;
    79     }
    79     }
    80 }
    80 }
    81 
    81 
       
    82 /* TryLock the mutex */
       
    83 int
       
    84 SDL_TryLockMutex(SDL_mutex * mutex)
       
    85 {
       
    86     int retval = 0;
       
    87     if (mutex == NULL) {
       
    88         return SDL_SetError("Passed a NULL mutex");
       
    89     }
       
    90 
       
    91     if (mutex->cpp_mutex.try_lock() == false) {
       
    92         retval = SDL_MUTEX_TIMEDOUT;
       
    93     }
       
    94     return retval;
       
    95 }
       
    96 
    82 /* Unlock the mutex */
    97 /* Unlock the mutex */
    83 extern "C"
    98 extern "C"
    84 int
    99 int
    85 SDL_mutexV(SDL_mutex * mutex)
   100 SDL_mutexV(SDL_mutex * mutex)
    86 {
   101 {