Skip to content

Commit

Permalink
Implemented Sem_Value for debug; get the current value of a semaphore.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 29, 2011
1 parent 51dcebb commit 18c086b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
10 changes: 10 additions & 0 deletions doomsday/engine/portable/include/sys_system.h
Expand Up @@ -64,7 +64,17 @@ void Sys_Unlock(mutex_t mutexHandle);

sem_t Sem_Create(uint32_t initialValue);
void Sem_Destroy(sem_t semaphore);

/**
* "Proberen" a semaphore. Blocks until the successful.
*/
void Sem_P(sem_t semaphore);

/**
* "Verhogen" a semaphore. Returns immediately.
*/
void Sem_V(sem_t semaphore);

uint32_t Sem_Value(sem_t semaphore);

#endif /* LIBDENG_FILESYS_SYSTEM_H */
20 changes: 9 additions & 11 deletions doomsday/engine/portable/src/sys_system.c
Expand Up @@ -375,11 +375,6 @@ void Sys_Unlock(mutex_t handle)
SDL_mutexV((SDL_mutex *) handle);
}

/**
* Create a new semaphore.
*
* @return New handle.
*/
sem_t Sem_Create(uint32_t initialValue)
{
return (sem_t) SDL_CreateSemaphore(initialValue);
Expand All @@ -393,9 +388,6 @@ void Sem_Destroy(sem_t semaphore)
}
}

/**
* "Proberen" a semaphore. Blocks until the successful.
*/
void Sem_P(sem_t semaphore)
{
if(semaphore)
Expand All @@ -404,13 +396,19 @@ void Sem_P(sem_t semaphore)
}
}

/**
* "Verhogen" a semaphore. Returns immediately.
*/
void Sem_V(sem_t semaphore)
{
if(semaphore)
{
SDL_SemPost((SDL_sem *) semaphore);
}
}

uint32_t Sem_Value(sem_t semaphore)
{
if(semaphore)
{
return (uint32_t)SDL_SemValue((SDL_sem*)semaphore);
}
return 0;
}

0 comments on commit 18c086b

Please sign in to comment.