Add ssem_get - SDL_SemValue equivalent

This commit is contained in:
twinaphex 2016-04-05 19:08:41 +02:00
parent db24cb1ec5
commit 001aa3ba4a
2 changed files with 17 additions and 0 deletions

View File

@ -41,6 +41,8 @@ ssem_t *ssem_new(int value);
void ssem_free(ssem_t *semaphore);
int ssem_get(ssem_t *semaphore);
void ssem_wait(ssem_t *semaphore);
void ssem_signal(ssem_t *semaphore);

View File

@ -77,6 +77,21 @@ void ssem_free(ssem_t *semaphore)
free((void*)semaphore);
}
int ssem_get(ssem_t *semaphore)
{
int val = 0;
if (!semaphore)
return 0;
slock_lock(semaphore->mutex);
val = semaphore->value;
slock_unlock(semaphore->mutex);
return val;
}
void ssem_wait(ssem_t *semaphore)
{
if (!semaphore)