acl  3.5.3.0
fiber_lock.h
浏览该文件的文档.
1 #ifndef FIBER_LOCK_INCLUDE_H
2 #define FIBER_LOCK_INCLUDE_H
3 
4 #include "fiber_define.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 /* fiber locking */
11 
12 /**
13  * fiber mutex, thread unsafety, one fiber mutex can only be used in the
14  * same thread, otherwise the result is unpredictable
15  */
17 
18 /**
19  * fiber read/write mutex, thread unsafety, can only be used in the sampe thread
20  */
22 
23 /**
24  * create one fiber mutex, can only be used in the same thread
25  * @return {ACL_FIBER_MUTEX*} fiber mutex returned
26  */
28 
29 /**
30  * free fiber mutex created by acl_fiber_mutex_create
31  * @param l {ACL_FIBER_MUTEX*} created by acl_fiber_mutex_create
32  */
34 
35 /**
36  * lock the specified fiber mutex, return immediately when locked, or will
37  * wait until the mutex can be used
38  * @param l {ACL_FIBER_MUTEX*} created by acl_fiber_mutex_create
39  */
41 
42 /**
43  * try lock the specified fiber mutex, return immediately no matter the mutex
44  * can be locked.
45  * @param l {ACL_FIBER_MUTEX*} created by acl_fiber_mutex_create
46  * @return {int} 0 returned when locking successfully, -1 when locking failed
47  */
49 
50 /**
51  * the fiber mutex be unlock by its owner fiber, fatal will happen when others
52  * release the fiber mutex
53  * @param l {ACL_FIBER_MUTEX*} created by acl_fiber_mutex_create
54  */
56 
57 /****************************************************************************/
58 
59 /**
60  * create one fiber rwlock, can only be operated in the sampe thread
61  * @return {ACL_FIBER_RWLOCK*}
62  */
64 
65 /**
66  * free rw mutex created by acl_fiber_rwlock_create
67  * @param l {ACL_FIBER_RWLOCK*} created by acl_fiber_rwlock_create
68  */
70 
71 /**
72  * lock the rwlock, if there is no any write locking on it, the
73  * function will return immediately; otherwise, the caller will wait for all
74  * write locking be released. Read lock on it will successful when returning
75  * @param l {ACL_FIBER_RWLOCK*} created by acl_fiber_rwlock_create
76  */
78 
79 /**
80  * try to locking the Readonly lock, return immediately no matter locking
81  * is successful.
82  * @param l {ACL_FIBER_RWLOCK*} crated by acl_fiber_rwlock_create
83  * @retur {int} 1 returned when successfully locked, or 0 returned if locking
84  * operation is failed.
85  */
87 
88 /**
89  * lock the rwlock in Write Lock mode, return until no any one locking it
90  * @param l {ACL_FIBER_RWLOCK*} created by acl_fiber_rwlock_create
91  */
93 
94 /**
95  * try to lock the rwlock in Write Lock mode. return immediately no matter
96  * locking is successful.
97  * @param l {ACL_FIBER_RWLOCK*} created by acl_fiber_rwlock_create
98  * @return {int} 1 returned when locking successfully, or 0 returned when
99  * locking failed
100  */
102 
103 /**
104  * the rwlock's Read-Lock owner unlock the rwlock
105  * @param l {ACL_FIBER_RWLOCK*} crated by acl_fiber_rwlock_create
106  */
108 
109 /**
110  * the rwlock's Write-Lock owner unlock the rwlock
111  * @param l {ACL_FIBER_RWLOCK*} created by acl_fiber_rwlock_create
112  */
114 
115 #ifdef __cplusplus
116 }
117 #endif
118 
119 #endif
FIBER_API void acl_fiber_mutex_free(ACL_FIBER_MUTEX *l)
FIBER_API int acl_fiber_rwlock_tryrlock(ACL_FIBER_RWLOCK *l)
FIBER_API ACL_FIBER_RWLOCK * acl_fiber_rwlock_create(void)
FIBER_API int acl_fiber_rwlock_trywlock(ACL_FIBER_RWLOCK *l)
#define FIBER_API
Definition: fiber_define.h:94
FIBER_API void acl_fiber_rwlock_wlock(ACL_FIBER_RWLOCK *l)
FIBER_API void acl_fiber_rwlock_wunlock(ACL_FIBER_RWLOCK *l)
FIBER_API void acl_fiber_rwlock_free(ACL_FIBER_RWLOCK *l)
FIBER_API void acl_fiber_rwlock_rlock(ACL_FIBER_RWLOCK *l)
FIBER_API int acl_fiber_mutex_trylock(ACL_FIBER_MUTEX *l)
FIBER_API void acl_fiber_mutex_lock(ACL_FIBER_MUTEX *l)
FIBER_API void acl_fiber_mutex_unlock(ACL_FIBER_MUTEX *l)
FIBER_API void acl_fiber_rwlock_runlock(ACL_FIBER_RWLOCK *l)
struct ACL_FIBER_RWLOCK ACL_FIBER_RWLOCK
Definition: fiber_lock.h:21
struct ACL_FIBER_MUTEX ACL_FIBER_MUTEX
Definition: fiber_lock.h:16
FIBER_API ACL_FIBER_MUTEX * acl_fiber_mutex_create(void)