comparison gtk/dw.c @ 1158:f86f556ff29d

Added dw_mutex_trylock() that functions like dw_mutex_lock() except it does not block if the mutex is already locked, it instead returns DW_MUTEX_TIMEOUT. Allowing threads to continue to do work while waiting to obtain a mutex.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 15 Sep 2011 21:13:59 +0000
parents 03b6d9fdfac0
children 924c8087a755
comparison
equal deleted inserted replaced
1157:79bd0aff0bc2 1158:f86f556ff29d
8519 if(pthread_self() == _dw_thread) 8519 if(pthread_self() == _dw_thread)
8520 gdk_threads_enter(); 8520 gdk_threads_enter();
8521 } 8521 }
8522 8522
8523 /* 8523 /*
8524 * Tries to gain access to the semaphore.
8525 * Parameters:
8526 * mutex: The handle to the mutex returned by dw_mutex_new().
8527 * Returns:
8528 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
8529 */
8530 int API dw_mutex_trylock(HMTX mutex)
8531 {
8532 if(pthread_mutex_trylock(mutex) == 0)
8533 return DW_ERROR_NONE;
8534 return DW_ERROR_TIMEOUT;
8535 }
8536
8537 /*
8524 * Reliquishes the access to the semaphore. 8538 * Reliquishes the access to the semaphore.
8525 * Parameters: 8539 * Parameters:
8526 * mutex: The handle to the mutex returned by dw_mutex_new(). 8540 * mutex: The handle to the mutex returned by dw_mutex_new().
8527 */ 8541 */
8528 void dw_mutex_unlock(HMTX mutex) 8542 void dw_mutex_unlock(HMTX mutex)