acl  3.5.3.0
fiber_sem.h 文件参考
#include "fiber_define.h"
+ fiber_sem.h 的引用(Include)关系图:
+ 此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

类型定义

typedef struct ACL_FIBER_SEM ACL_FIBER_SEM
 

函数

FIBER_API ACL_FIBER_SEMacl_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)
 

类型定义说明

◆ ACL_FIBER_SEM

typedef struct ACL_FIBER_SEM ACL_FIBER_SEM

在文件 fiber_sem.h13 行定义.

函数说明

◆ acl_fiber_sem_create()

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
返回
{ACL_FIBER_SEM *}

◆ acl_fiber_sem_free()

FIBER_API void acl_fiber_sem_free ( ACL_FIBER_SEM sem)

free fiber semaphore

参数
{ACL_FIBER_SEM*}

◆ acl_fiber_sem_get_tid()

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
返回
{unsigned long} thread ID of the thread binding the semaphore

◆ acl_fiber_sem_num()

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

◆ acl_fiber_sem_post()

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
返回
{int} the current semaphore value returned, -1 returned if the current thread ID is not same as the semaphore's owner ID

◆ acl_fiber_sem_set_tid()

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
{unsignedlong} the thread ID to be specificed with the semaphore

◆ acl_fiber_sem_trywait()

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
返回
{int} value(>=0) returned when waiting ok, otherwise -1 will be returned if the caller's thread isn't same as the semaphore thread or the semaphore's value is 0

◆ acl_fiber_sem_wait()

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
返回
{int} the semaphore value returned, if the caller's thread isn't same as the semaphore owner's thread, -1 will be returned