Mercurial > dwindows
comparison gtk3/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 |
---|---|
7397 if(pthread_self() == _dw_thread) | 7397 if(pthread_self() == _dw_thread) |
7398 gdk_threads_enter(); | 7398 gdk_threads_enter(); |
7399 } | 7399 } |
7400 | 7400 |
7401 /* | 7401 /* |
7402 * Tries to gain access to the semaphore. | |
7403 * Parameters: | |
7404 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
7405 * Returns: | |
7406 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked. | |
7407 */ | |
7408 int API dw_mutex_trylock(HMTX mutex) | |
7409 { | |
7410 if(pthread_mutex_trylock(mutex) == 0) | |
7411 return DW_ERROR_NONE; | |
7412 return DW_ERROR_TIMEOUT; | |
7413 } | |
7414 | |
7415 /* | |
7402 * Reliquishes the access to the semaphore. | 7416 * Reliquishes the access to the semaphore. |
7403 * Parameters: | 7417 * Parameters: |
7404 * mutex: The handle to the mutex returned by dw_mutex_new(). | 7418 * mutex: The handle to the mutex returned by dw_mutex_new(). |
7405 */ | 7419 */ |
7406 void dw_mutex_unlock(HMTX mutex) | 7420 void dw_mutex_unlock(HMTX mutex) |