acl
3.5.3.0
|
宏定义 | |
#define | FIBER_EVENT_KERNEL 0 /* epoll/kqueue/iocp */ |
#define | FIBER_EVENT_POLL 1 /* poll */ |
#define | FIBER_EVENT_SELECT 2 /* select */ |
#define | FIBER_EVENT_WMSG 3 /* win message */ |
类型定义 | |
typedef ACL_FIBER *(* | FIBER_ALLOC_FN) (void(*) (ACL_FIBER *), size_t)) |
typedef ACL_FIBER *(* | FIBER_ORIGIN_FN) (void)) |
typedef void(* | FIBER_MSG_PRE_WRITE_FN) (void *ctx, const char *fmt, va_list ap) |
typedef void(* | FIBER_MSG_WRITE_FN) (void *ctx, const char *fmt, va_list ap) |
#define FIBER_EVENT_KERNEL 0 /* epoll/kqueue/iocp */ |
start the fiber schedule process with the specified event type, the default event type is FIBER_EVENT_KERNEL. acl_fiber_schedule using the default event type. FIBER_EVENT_KERNEL is diffrent for diffrent OS platform: Linux: epoll; BSD: kqueue; Windows: iocp.
event_mode | {int} the event type, defined as FIBER_EVENT_XXX |
在文件 fiber_base.h 第 189 行定义.
#define FIBER_EVENT_POLL 1 /* poll */ |
在文件 fiber_base.h 第 190 行定义.
#define FIBER_EVENT_SELECT 2 /* select */ |
在文件 fiber_base.h 第 191 行定义.
#define FIBER_EVENT_WMSG 3 /* win message */ |
在文件 fiber_base.h 第 192 行定义.
在文件 fiber_base.h 第 11 行定义.
typedef void(* FIBER_MSG_PRE_WRITE_FN) (void *ctx, const char *fmt, va_list ap) |
log function type used in fiber logging process, should be set by the function acl_fiber_msg_pre_write
ctx | {void*} the user's context |
fmt | {const char*} format of parameters |
ap | {va_list} list of parameters |
在文件 fiber_base.h 第 283 行定义.
typedef void(* FIBER_MSG_WRITE_FN) (void *ctx, const char *fmt, va_list ap) |
log function type used in fiber logging process, should be set by the function acl_fiber_msg_register. This can be used by user for get the logging information of fiber
ctx | {void*} the user's context |
fmt | {const char*} format of parameters |
ap | {va_list} list of parameters |
在文件 fiber_base.h 第 293 行定义.
typedef ACL_FIBER*(* FIBER_ORIGIN_FN) (void)) |
在文件 fiber_base.h 第 12 行定义.
check if the specified fiber has been canceled
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
FIBER_API void acl_fiber_check_timer | ( | size_t | max | ) |
create one fiber in background for freeing the dead fibers, specify the maximum fibers in every recyling process
max | {size_t} the maximum fibers to freed in every recyling process |
check if the specified fiber's socket has been closed by another fiber
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
create and start one fiber
fn | {void (*)(ACL_FIBER*, void*)} the callback of fiber running |
arg | {void*} the second parameter of the callback fn |
size | {size_t} the virual memory size of the fiber created |
FIBER_API ACL_FIBER* acl_fiber_create_timer | ( | unsigned int | milliseconds, |
size_t | size, | ||
void(*)(ACL_FIBER *, void *) | fn, | ||
void * | ctx | ||
) |
create one fiber timer
milliseconds | {unsigned int} the timer wakeup milliseconds |
size | {size_t} the virtual memory of the created fiber |
fn | {void (*)(ACL_FIBER*, void*)} the callback when fiber wakeup |
ctx | {void*} the second parameter of the callback fn |
FIBER_API unsigned int acl_fiber_delay | ( | unsigned int | milliseconds | ) |
let the current fiber sleep for a while
milliseconds | {unsigned int} the milliseconds to sleep |
get the error number of assosiated fiber
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
FIBER_API void* acl_fiber_get_specific | ( | int | key | ) |
get the current fiber's local object assosiated with the specified indexed key
key | {int} the integer value returned by acl_fiber_set_specific @retur {void*} NULL returned if no fiber local object with the specified key |
FIBER_API int acl_fiber_gettimeofday | ( | struct timeval * | tv, |
struct timezone * | tz | ||
) |
FIBER_API void acl_fiber_hook_api | ( | int | onoff | ) |
set flag if the system API should be hooked, default value is 1 internal
onoff | {int} if need to hook the system API |
get the fiber ID of the specified fiber
fiber | {const ACL_FIBER*} the specified fiber object |
fiber | {ACL_FIBER*} |
yesno | {int} |
kill the suspended fiber and notify it to exit
fiber | {const ACL_FIBER*} the specified fiber, NOT NULL |
check if the specified fiber has been killed
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
FIBER_API int acl_fiber_last_error | ( | void | ) |
get the system error number of last system API calling
FIBER_API const char* acl_fiber_last_serror | ( | void | ) |
get the error information of last system API calling
FIBER_API void acl_fiber_memstat | ( | void | ) |
FIBER_API void acl_fiber_msg_pre_write | ( | FIBER_MSG_PRE_WRITE_FN | pre_write, |
void * | ctx | ||
) |
register the user's callback
pre_write | {MSG_PRE_WRITE_FN} |
ctx | {void*} |
FIBER_API void acl_fiber_msg_register | ( | FIBER_MSG_WRITE_FN | write_fn, |
void * | ctx | ||
) |
set the user's log saving function when process started
write_fn | {MSG_WRITE_FN} log function defined by the user |
ctx | {void*} parameter will be transfered to write_fn |
FIBER_API void acl_fiber_msg_stdout_enable | ( | int | onoff | ) |
if showing the fiber schedule process's log to stdout
onoff | {int} log will be showed to stdout if onoff isn't 0 |
FIBER_API void acl_fiber_msg_unregister | ( | void | ) |
cleanup the registered log callback by acl_fiber_msg_register
FIBER_API unsigned acl_fiber_ndead | ( | void | ) |
get the fibers count in deading status
FIBER_API unsigned acl_fiber_number | ( | void | ) |
get the fibers count in aliving status
add the suspended fiber into resuming queue
fiber | {ACL_FIBER*} the fiber, NOT NULL |
FIBER_API void acl_fiber_register | ( | FIBER_ALLOC_FN | alloc_fn, |
FIBER_ORIGIN_FN | origin_fn | ||
) |
reset the timer milliseconds time before the timer fiber wakeup
timer | {ACL_FIBER*} the fiber created by acl_fiber_create_timer |
milliseconds | {unsigned int} the new timer wakeup milliseconds |
get the current running fiber @retur {ACL_FIBER*} if no running fiber NULL will be returned
FIBER_API void acl_fiber_schedule | ( | void | ) |
start the fiber schedule process, the fibers in the ready quque will be started in sequence.
FIBER_API void acl_fiber_schedule_init | ( | int | on | ) |
set the fiber schedule process with automatically, in this way, when one fiber was created, the schedule process will start automatically, but only the first fiber was started, so you can create the other fibers in this fiber. The default schedule mode is non-automatically, you should call the acl_fiber_schedule or acl_fiber_schedule_with explicit
FIBER_API void acl_fiber_schedule_set_event | ( | int | event_mode | ) |
set the event type, the default type is FIBER_EVENT_KERNEL, this function must be called before acl_fiber_schedule.
event_mode | {int} the event type, defined as FIBER_EVENT_XXX |
FIBER_API void acl_fiber_schedule_stop | ( | void | ) |
stop the fiber schedule process, all fibers will be stopped
FIBER_API void acl_fiber_schedule_with | ( | int | event_mode | ) |
FIBER_API int acl_fiber_scheduled | ( | void | ) |
check if the current thread is in fiber schedule status
FIBER_API unsigned int acl_fiber_self | ( | void | ) |
get the current running fiber's ID
FIBER_API void acl_fiber_set_dns | ( | const char * | ip, |
int | port | ||
) |
set the DNS service addr
ip | {const char*} ip of the DNS service |
port | {int} port of the DNS service |
set the error number to the specified fiber object
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running fiber will be used |
errnum | {int} the error number |
FIBER_API void acl_fiber_set_error | ( | int | errnum | ) |
set the system error number
errnum | {int} the error number |
FIBER_API int acl_fiber_set_fdlimit | ( | int | limit | ) |
set the fd limit for the current process
limit | {int} the fd limit to be set |
FIBER_API int acl_fiber_set_specific | ( | int * | key, |
void * | ctx, | ||
void(*)(void *) | free_fn | ||
) |
set the current fiber's local object
key | {int*} the addr of indexed key, its initial value should <= 0, and one integer which > 0 will be set for it; the fiber local object will be assosiated with the indexed key. |
ctx | {void *} the fiber local object |
free_fn | {void (*)(void*)} the callback will be called before the current fiber exiting |
wakeup the suspended fiber with the assosiated signal number
fiber | {const ACL_FIBER*} the specified fiber, NOT NULL |
signum | {int} SIGINT, SIGKILL, SIGTERM ... refer to bits/signum.h |
check if the specified fiber has been signaled
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
get the signal number got from other fiber
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running @retur {int} the signal number got |
FIBER_API unsigned int acl_fiber_sleep | ( | unsigned int | seconds | ) |
let the current fiber sleep for a while
seconds | {unsigned int} the seconds to sleep |
get the assosiated fiber's status
fiber | {ACL_FIBER*} the specified fiber, if NULL the current running |
FIBER_API const char* acl_fiber_strerror | ( | int | errnum, |
char * | buf, | ||
size_t | size | ||
) |
convert errno to string
errnum | {int} |
buf | {char*} hold the result |
size | {size_t} buf's size @retur {const char*} the addr of buf |
FIBER_API void acl_fiber_switch | ( | void | ) |
suspend the current fiber and switch to run the next ready fiber
FIBER_API int acl_fiber_yield | ( | void | ) |
suspend the current running fiber