acl  3.5.3.0
fiber_event.h
浏览该文件的文档.
1 #ifndef FIBER_EVENT_INCLUDE_H
2 #define FIBER_EVENT_INCLUDE_H
3 
4 #include "fiber_define.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 /* fiber_event.c */
11 
12 /**
13  * fiber event mutex object based on IO event, which is thread safety. That's
14  * to say one event object can used in different threads
15  */
17 
18 /**
19  * when the fiber_event is used in multiple threads for sync, if there're
20  * many threads, the flag FIBER_FLAG_USE_MUTEX should be set to avoid internal
21  * thundering herd which maybe happen by using atomic; if the threads' number
22  * is less than one hundred, the flag FIBER_FLAG_USE_MUTEX needn't be set
23  */
24 #define FIBER_FLAG_USE_MUTEX (1 << 0)
25 
26 /**
27  * if this flag is set, msg_fatal will be used other msg_error when error
28  * happened, this flag is optional for users
29  */
30 #define FIBER_FLAG_USE_FATAL (1 << 1)
31 
32 /**
33  * create fiber event mutex which can be used in fibers mode or threads mode
34  * @param flag {unsigned} define as FIBER_FLAG_XXX above
35  * @return {ACL_FIBER_EVENT *}
36  */
38 
39 /**
40  * free event mutex returned by acl_fiber_event_create
41  * @param {ACL_FIBER_EVENT *}
42  */
44 
45 /**
46  * wait for event can be available
47  * @param {ACL_FIBER_EVENT *}
48  * @return {int} 0 returned if successful, or -1 if error happened
49  */
51 
52 /**
53  * try to wait for event can be available
54  * @param {ACL_FIBER_EVENT *}
55  * @return {int} 0 returned if successful, or -1 if the event been locked
56  */
58 
59 /**
60  * the event's owner notify the waiters that the event mutex can be available,
61  * and the waiter will get the event mutex
62  * @param {ACL_FIBER_EVENT *}
63  * @return {int} 0 returned if successful, or -1 if error happened
64  */
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif
FIBER_API int acl_fiber_event_trywait(ACL_FIBER_EVENT *event)
FIBER_API void acl_fiber_event_free(ACL_FIBER_EVENT *event)
#define FIBER_API
Definition: fiber_define.h:94
FIBER_API int acl_fiber_event_notify(ACL_FIBER_EVENT *event)
FIBER_API ACL_FIBER_EVENT * acl_fiber_event_create(unsigned flag)
struct ACL_FIBER_EVENT ACL_FIBER_EVENT
Definition: fiber_event.h:16
FIBER_API int acl_fiber_event_wait(ACL_FIBER_EVENT *event)