Mercurial > dwindows
comparison os2/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 | 58b5374355ab |
children | 924c8087a755 |
comparison
equal
deleted
inserted
replaced
1157:79bd0aff0bc2 | 1158:f86f556ff29d |
---|---|
9024 else | 9024 else |
9025 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT); | 9025 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT); |
9026 } | 9026 } |
9027 | 9027 |
9028 /* | 9028 /* |
9029 * Tries to gain access to the semaphore. | |
9030 * Parameters: | |
9031 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
9032 * Returns: | |
9033 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked. | |
9034 */ | |
9035 int API dw_mutex_trylock(HMTX mutex) | |
9036 { | |
9037 if(DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN) == NO_ERROR) | |
9038 return DW_ERROR_NONE; | |
9039 return DW_ERROR_TIMEOUT; | |
9040 } | |
9041 | |
9042 /* | |
9029 * Reliquishes the access to the semaphore. | 9043 * Reliquishes the access to the semaphore. |
9030 * Parameters: | 9044 * Parameters: |
9031 * mutex: The handle to the mutex returned by dw_mutex_new(). | 9045 * mutex: The handle to the mutex returned by dw_mutex_new(). |
9032 */ | 9046 */ |
9033 void API dw_mutex_unlock(HMTX mutex) | 9047 void API dw_mutex_unlock(HMTX mutex) |