acl
3.5.3.0
|
#include "fiber_define.h"
类型定义 | |
typedef struct ACL_FIBER_SEM | ACL_FIBER_SEM |
函数 | |
FIBER_API ACL_FIBER_SEM * | acl_fiber_sem_create (int num) |
FIBER_API void | acl_fiber_sem_free (ACL_FIBER_SEM *sem) |
FIBER_API unsigned long | acl_fiber_sem_get_tid (ACL_FIBER_SEM *sem) |
FIBER_API void | acl_fiber_sem_set_tid (ACL_FIBER_SEM *sem, unsigned long tid) |
FIBER_API int | acl_fiber_sem_wait (ACL_FIBER_SEM *sem) |
FIBER_API int | acl_fiber_sem_trywait (ACL_FIBER_SEM *sem) |
FIBER_API int | acl_fiber_sem_post (ACL_FIBER_SEM *sem) |
FIBER_API int | acl_fiber_sem_num (ACL_FIBER_SEM *sem) |
typedef struct ACL_FIBER_SEM ACL_FIBER_SEM |
在文件 fiber_sem.h 第 13 行定义.
FIBER_API ACL_FIBER_SEM* acl_fiber_sem_create | ( | int | num | ) |
create one fiber semaphore, and binding it with the current thread
num | {int} the initial value of the semaphore, must >= 0 |
FIBER_API void acl_fiber_sem_free | ( | ACL_FIBER_SEM * | sem | ) |
free fiber semaphore
{ACL_FIBER_SEM | *} |
FIBER_API unsigned long acl_fiber_sem_get_tid | ( | ACL_FIBER_SEM * | sem | ) |
get the thread binding the specificed fiber sem
sem | {ACL_FIBER_SEM*} created by acl_fiber_sem_create |
FIBER_API int acl_fiber_sem_num | ( | ACL_FIBER_SEM * | sem | ) |
get the specificed semaphore's value
sem | {ACL_FIBER_SEM*} created by acl_fiber_sem_create @retur {int} current semaphore's value returned |
FIBER_API int acl_fiber_sem_post | ( | ACL_FIBER_SEM * | sem | ) |
add 1 to the semaphore, if there are other fibers waiting for semaphore, one waiter will be wakeuped
sem | {ACL_FIBER_SEM *} created by acl_fiber_sem_create |
FIBER_API void acl_fiber_sem_set_tid | ( | ACL_FIBER_SEM * | sem, |
unsigned long | tid | ||
) |
set the thread ID the semaphore belongs to, changing the owner of the fiber semaphore, when this function was called, the value of the semaphore must be zero, otherwise fatal will happen.
sem | {ACL_FIBER_SEM*} created by acl_fiber_sem_create |
{unsigned | long} the thread ID to be specificed with the semaphore |
FIBER_API int acl_fiber_sem_trywait | ( | ACL_FIBER_SEM * | sem | ) |
try to wait semaphore until > 0, if semaphore is 0, -1 returned immediately, otherwise semaphore will be decreased 1 and the semaphore's value is returned
sem | {ACL_FIBER_SEM *} created by acl_fiber_sem_create |
FIBER_API int acl_fiber_sem_wait | ( | ACL_FIBER_SEM * | sem | ) |
wait for semaphore until > 0, semaphore will be -1 when returned
sem | {ACL_FIBER_SEM *} created by acl_fiber_sem_create |