29 #ifndef HAS_WORKING_SEMAPHORE
43 if (value > AST_SEM_VALUE_MAX) {
50 ast_mutex_init(&sem->
mutex);
51 ast_cond_init(&sem->
cond, NULL);
57 ast_mutex_destroy(&sem->
mutex);
58 ast_cond_destroy(&sem->
cond);
66 ast_assert(sem->
count >= 0);
68 if (sem->
count == AST_SEM_VALUE_MAX) {
78 ast_cond_signal(&sem->
cond);
89 ast_assert(sem->
count >= 0);
93 while (sem->
count == 0) {
94 res = ast_cond_wait(&sem->
cond, &sem->
mutex);
114 ast_assert(sem->
count >= 0);
118 while (sem->
count == 0) {
119 res = ast_cond_timedwait(&sem->
cond, &sem->
mutex, abs_timeout);
138 ast_assert(sem->
count >= 0);
int ast_sem_destroy(struct ast_sem *sem)
Destroy a semaphore.
Asterisk main include file. File version handling, generic pbx functions.
int ast_sem_post(struct ast_sem *sem)
Increments the semaphore, unblocking a waiter if necessary.
int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)
Decrements the semaphore, waiting until abs_timeout.
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
int ast_sem_getvalue(struct ast_sem *sem, int *sval)
Gets the current value of the semaphore.
int ast_sem_wait(struct ast_sem *sem)
Decrements the semaphore.
int ast_sem_init(struct ast_sem *sem, int pshared, unsigned int value)
Initialize a semaphore.