Mercurial > dwindows
comparison mac/dw.m @ 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 | e6a2f57c0842 |
children | 924c8087a755 |
comparison
equal
deleted
inserted
replaced
1157:79bd0aff0bc2 | 1158:f86f556ff29d |
---|---|
8450 } | 8450 } |
8451 else | 8451 else |
8452 { | 8452 { |
8453 pthread_mutex_lock(mutex); | 8453 pthread_mutex_lock(mutex); |
8454 } | 8454 } |
8455 } | |
8456 | |
8457 /* | |
8458 * Tries to gain access to the semaphore. | |
8459 * Parameters: | |
8460 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
8461 * Returns: | |
8462 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked. | |
8463 */ | |
8464 int API dw_mutex_trylock(HMTX mutex) | |
8465 { | |
8466 if(pthread_mutex_trylock(mutex) == 0) | |
8467 return DW_ERROR_NONE; | |
8468 return DW_ERROR_TIMEOUT; | |
8455 } | 8469 } |
8456 | 8470 |
8457 /* | 8471 /* |
8458 * Reliquishes the access to the semaphore. | 8472 * Reliquishes the access to the semaphore. |
8459 * Parameters: | 8473 * Parameters: |