2019-07-27 22:44:32 +08:00
|
|
|
|
#ifndef LIB_ACL_FIBER_INCLUDE_H
|
2018-11-30 14:38:22 +08:00
|
|
|
|
#define LIB_ACL_FIBER_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
|
|
//typedef struct ACL_VSTREAM ACL_VSTREAM;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍗忕▼缁撴瀯绫诲瀷
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_FIBER ACL_FIBER;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璁剧疆鏄惁闇€瑕<EFBFBD> hook 绯荤粺涓殑 IO 鐩稿叧鐨<EFBFBD> API锛屽唴閮ㄧ己鐪佸€间负 1
|
|
|
|
|
* @param onoff {int} 鏄惁闇€瑕<EFBFBD> hook
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_hook_api(int onoff);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓涓€涓崗绋<EFBFBD>
|
|
|
|
|
* @param fn {void (*)(ACL_FIBER*, void*)} 鍗忕▼杩愯鏃剁殑鍥炶皟鍑芥暟鍦板潃
|
|
|
|
|
* @param arg {void*} 鍥炶皟 fn 鍑芥暟鏃剁殑绗簩涓弬鏁<EFBFBD>
|
|
|
|
|
* @param size {size_t} 鎵€鍒涘缓鍗忕▼鎵€鍗犳爤绌洪棿澶у皬
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {ACL_FIBER*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER* acl_fiber_create(void (*fn)(ACL_FIBER*, void*),
|
|
|
|
|
void* arg, size_t size);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 杩斿洖褰撳墠绾跨▼涓浜庢秷浜$姸鎬佺殑鍗忕▼鏁<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @retur {int}
|
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_ndead(void);
|
|
|
|
|
|
|
|
|
|
void acl_fiber_check_timer(size_t max);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 杩斿洖褰撳墠姝e湪杩愯鐨勫崗绋嬪璞<EFBFBD>
|
|
|
|
|
* @retur {ACL_FIBER*} 杩斿洖 NULL 琛ㄧず褰撳墠娌℃湁姝e湪杩愯鐨勫崗绋<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER* acl_fiber_running(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱鎵€缁欏崗绋嬬殑鍗忕▼ ID 鍙<EFBFBD>
|
|
|
|
|
* @param fiber {const ACL_FIBER*} acl_fiber_create 鍒涘缓鐨勫崗绋嬪璞★紝蹇呴』闈炵┖
|
|
|
|
|
* @return {unsigned int} 鍗忕▼ ID 鍙<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
unsigned int acl_fiber_id(const ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱褰撳墠鎵€杩愯鐨勫崗绋嬬殑 ID 鍙<EFBFBD>
|
|
|
|
|
* @return {unsigned int} 褰撳墠杩愯鍗忕▼鐨<EFBFBD> ID 鍙<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
unsigned int acl_fiber_self(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璁剧疆鎵€缁欏崗绋嬬殑閿欒鍙<EFBFBD>
|
|
|
|
|
* @param fiber {ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝涓<EFBFBD> NULL 鍒欎娇鐢ㄥ綋鍓嶈繍琛岀殑鍗忕▼
|
|
|
|
|
* @param errnum {int} 閿欒鍙<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_set_errno(ACL_FIBER* fiber, int errnum);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱鎸囧畾鍗忕▼鐨勯敊璇彿
|
|
|
|
|
* @param fiber {ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝鑻ヤ负 NULL 鍒欎娇鐢ㄥ綋鍓嶅崗绋嬪璞<EFBFBD>
|
|
|
|
|
* @return {int} 鎵€缁欏崗绋嬮敊璇彿
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_errno(ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱褰撳墠绯荤粺绾х殑 errno 鍙<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_sys_errno(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璁剧疆褰撳墠绯荤粺鐨<EFBFBD> errno 鍙<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param errnum {int}
|
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_sys_errno_set(int errnum);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鏄惁淇濇寔鎵€鎸囧畾鍗忕▼鐨勯敊璇彿锛屽綋璁剧疆涓衡€滀繚鎸佲€濆悗锛屽垯璇ュ崗绋嬩粎淇濇寔褰撳墠鐘舵€佷笅鐨<EFBFBD>
|
|
|
|
|
* 閿欒鍙凤紝涔嬪悗璇ュ崗绋嬬殑閿欒鍙<EFBFBD> errno 灏嗕笉鍐嶆敼鍙橈紝璧板埌鍐嶆璋冪敤鏈嚱鏁板彇娑堜繚鎸<EFBFBD>
|
|
|
|
|
* @param fiber {ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝涓<EFBFBD> NULL 鍒欎娇鐢ㄥ綋鍓嶈繍琛岀殑鍗忕▼
|
|
|
|
|
* @param yesno {int} 鏄惁淇濇寔
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_keep_errno(ACL_FIBER* fiber, int yesno);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱鎸囧畾鍗忕▼鐨勫綋鍓嶇姸鎬<EFBFBD>
|
|
|
|
|
* @param fiber {const ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝涓<EFBFBD> NULL 鍒欎娇鐢ㄥ綋鍓嶅崗绋<EFBFBD>
|
|
|
|
|
* @return {int} 鍗忕▼鐘舵€<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_status(const ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閫氱煡澶勪簬浼戠湢鐘舵€佺殑鍗忕▼閫€鍑<EFBFBD>
|
|
|
|
|
* @param fiber {const ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝蹇呴』闈<EFBFBD> NULL
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_kill(ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 妫€鏌ユ湰鍗忕▼鏄惁琚叾瀹冨崗绋嬮€氱煡閫€鍑<EFBFBD>
|
|
|
|
|
* @param fiber {const ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝鑻ヤ负 NULL 鍒欒嚜鍔ㄤ娇鐢ㄥ綋鍓<EFBFBD>
|
|
|
|
|
* 姝e湪杩愯鐨勫崗绋<EFBFBD>
|
|
|
|
|
* @return {int} 杩斿洖鍊间负 0 琛ㄧず娌℃湁琚€氱煡閫€鍑猴紝闈<EFBFBD> 0 琛ㄧず琚€氱煡閫€鍑<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_killed(ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍞ら啋鍥<EFBFBD> IO 绛夊師鍥犲浜庝紤鐪犵殑鍗忕▼
|
|
|
|
|
* @param fiber {const ACL_FIBER*} 鍗忕▼瀵硅薄锛屽繀椤婚潪 NULL
|
|
|
|
|
* @param signum {int} SIGINT, SIGKILL, SIGTERM ... 鍙傝€冪郴缁熶腑 bits/signum.h
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_signal(ACL_FIBER* fiber, int signum);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱鍏跺畠鍗忕▼鍙戦€佺粰鎸囧畾鍗忕▼鐨勪俊鍙峰€<EFBFBD>
|
|
|
|
|
* @param fiber {const ACL_FIBER*} 鎸囧畾鐨勫崗绋嬪璞★紝涓<EFBFBD> NULL 鏃跺垯浣跨敤褰撳墠鍗忕▼
|
|
|
|
|
* @retur {int} 杩斿洖鎸囧畾鍗忕▼鏀跺埌鐨勪俊鍙峰€<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_signum(ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 灏嗗綋鍓嶈繍琛岀殑鍗忕▼鎸傝捣锛岀敱璋冨害鍣ㄩ€夋嫨涓嬩竴涓渶瑕佽繍琛岀殑鍗忕▼
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_yield(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 灏嗘寚瀹氬崗绋嬪璞$疆鍏ュ緟杩愯闃熷垪涓<EFBFBD>
|
|
|
|
|
* @param fiber {ACL_FIBER*} 鎸囧畾鍗忕▼锛屽繀椤婚潪 NULL
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_ready(ACL_FIBER* fiber);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 灏嗗綋鍓嶈繍琛岀殑鍗忕▼鎸傝捣锛屽悓鏃舵墽琛岀瓑寰呴槦鍒椾笅涓€涓緟杩愯鐨勫崗绋<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_switch(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璋冪敤鏈嚱鏁板惎鍔ㄥ崗绋嬬殑璋冨害杩囩▼
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_schedule(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璋冪敤鏈嚱鏁版娴嬪綋鍓嶇嚎绋嬫槸鍚﹀浜庡崗绋嬭皟搴︾姸鎬<EFBFBD>
|
|
|
|
|
* @return {int} 0 琛ㄧず闈炲崗绋嬬姸鎬侊紝闈<EFBFBD> 0 琛ㄧず澶勪簬鍗忕▼璋冨害鐘舵€<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_scheduled(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍋滄鍗忕▼杩囩▼
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_schedule_stop(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浣垮綋鍓嶈繍琛岀殑鍗忕▼浼戠湢鎸囧畾姣鏁<EFBFBD>
|
|
|
|
|
* @param milliseconds {unsigned int} 鎸囧畾瑕佷紤鐪犵殑姣鏁<EFBFBD>
|
|
|
|
|
* @return {unsigned int} 鏈崗绋嬩紤鐪犲悗鍐嶆琚敜閱掑悗鍓╀綑鐨勬绉掓暟
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
unsigned int acl_fiber_delay(unsigned int milliseconds);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浣垮綋鍓嶈繍琛岀殑鍗忕▼浼戠湢鎸囧畾绉掓暟
|
|
|
|
|
* @param seconds {unsigned int} 鎸囧畾瑕佷紤鐪犵殑绉掓暟
|
|
|
|
|
* @return {unsigned int} 鏈崗绋嬩紤鐪犲悗鍐嶆琚敜閱掑悗鍓╀綑鐨勭鏁<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
unsigned int acl_fiber_sleep(unsigned int seconds);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓涓€涓崗绋嬬敤浣滃畾鏃跺櫒
|
|
|
|
|
* @param milliseconds {unsigned int} 鎵€鍒涘缓瀹氭椂鍣ㄨ鍞ら啋鐨勬绉掓暟
|
|
|
|
|
* @param size {size_t} 鎵€鍒涘缓鍗忕▼鐨勬爤绌洪棿澶у皬
|
|
|
|
|
* @param fn {void (*)(ACL_FIBER*, void*)} 瀹氭椂鍣ㄥ崗绋嬭鍞ら啋鏃剁殑鍥炶皟鍑芥暟
|
|
|
|
|
* @param ctx {void*} 鍥炶皟 fn 鍑芥暟鏃剁殑绗簩涓弬鏁<EFBFBD>
|
|
|
|
|
* @return {ACL_FIBER*} 鏂板垱寤虹殑瀹氭椂鍣ㄥ崗绋<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER* acl_fiber_create_timer(unsigned int milliseconds, size_t size,
|
|
|
|
|
void (*fn)(ACL_FIBER*, void*), void* ctx);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍦ㄥ畾鏃跺櫒鍗忕▼鏈鍞ら啋鍓嶏紝鍙互閫氳繃鏈嚱鏁伴噸缃鍗忕▼琚敜閱掔殑鏃堕棿
|
|
|
|
|
* @param timer {ACL_FIBER*} 鐢<EFBFBD> acl_fiber_create_timer 鍒涘缓鐨勫畾鏃跺櫒鍗忕▼
|
|
|
|
|
* @param milliseconds {unsigned int} 鎸囧畾璇ュ畾鏃跺櫒鍗忕▼琚敜閱掔殑姣鏁<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_reset_timer(ACL_FIBER* timer, unsigned int milliseconds);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鏈嚱鏁拌缃<EFBFBD> DNS 鏈嶅姟鍣ㄧ殑鍦板潃
|
|
|
|
|
* @param ip {const char*} DNS 鏈嶅姟鍣<EFBFBD> IP 鍦板潃
|
|
|
|
|
* @param port {int} DNS 鏈嶅姟鍣ㄧ殑绔彛
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_set_dns(const char* ip, int port);
|
|
|
|
|
|
|
|
|
|
/* for fiber specific */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璁惧畾褰撳墠鍗忕▼鐨勫眬閮ㄥ彉閲<EFBFBD>
|
|
|
|
|
* @param key {int*} 鍗忕▼灞€閮ㄥ彉閲忕殑绱㈠紩閿殑鍦板潃锛屽垵濮嬫椂璇ュ€煎簲 <= 0锛屽唴閮ㄤ細鑷姩
|
|
|
|
|
* 鍒嗛厤涓€涓<EFBFBD> > 0 鐨勭储寮曢敭锛屽苟缁欒鍦板潃璧嬪€硷紝鍚庨潰鐨勫崗绋嬪彲浠ュ鐢ㄨ鍊艰缃悇鑷殑
|
|
|
|
|
* 灞€閮ㄥ彉閲忥紝璇ユ寚閽堝繀椤婚潪 NULL
|
|
|
|
|
* @param ctx {void *} 鍗忕▼灞€閮ㄥ彉閲<EFBFBD>
|
|
|
|
|
* @param free_fn {void (*)(void*)} 褰撳崗绋嬮€€鍑烘椂浼氳皟鐢ㄦ鍑芥暟閲婃斁鍗忕▼灞€閮ㄥ彉閲<EFBFBD>
|
|
|
|
|
* @return {int} 杩斿洖鎵€璁剧疆鐨勫崗绋嬪眬閮ㄥ彉閲忕殑閿€硷紝杩斿洖 -1 琛ㄧず褰撳墠鍗忕▼涓嶅瓨鍦<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_set_specific(int* key, void* ctx, void (*free_fn)(void*));
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱褰撳墠鍗忕▼灞€閮ㄥ彉閲<EFBFBD>
|
|
|
|
|
* @param key {int} 鐢<EFBFBD> acl_fiber_set_specific 杩斿洖鐨勯敭鍊<EFBFBD>
|
|
|
|
|
* @retur {void*} 杩斿洖 NULL 琛ㄧず涓嶅瓨鍦<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void* acl_fiber_get_specific(int key);
|
|
|
|
|
|
|
|
|
|
/* fiber locking */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍗忕▼浜掓枼閿侊紝绾跨▼闈炲畨鍏紝鍙兘鐢ㄥ湪鍚屼竴绾跨▼鍐<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_FIBER_MUTEX ACL_FIBER_MUTEX;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍗忕▼璇诲啓閿侊紝绾跨▼闈炲畨鍏紝鍙兘鐢ㄥ湪鍚屼竴绾跨▼鍐<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_FIBER_RWLOCK ACL_FIBER_RWLOCK;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓鍗忕▼浜掓枼閿侊紝绾跨▼闈炲畨鍏紝鍙兘鐢ㄥ湪鍚屼竴绾跨▼鍐<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {ACL_FIBER_MUTEX*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER_MUTEX* acl_fiber_mutex_create(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閲婃斁鍗忕▼浜掓枼閿<EFBFBD>
|
|
|
|
|
* @param l {ACL_FIBER_MUTEX*} 鐢<EFBFBD> acl_fiber_mutex_create 鍒涘缓鐨勫崗绋嬩簰鏂ラ攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_mutex_free(ACL_FIBER_MUTEX* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬩簰鏂ラ攣杩涜闃诲寮忓姞閿侊紝濡傛灉鍔犻攣鎴愬姛鍒欒繑鍥烇紝鍚﹀垯鍒欓樆濉<EFBFBD>
|
|
|
|
|
* @param l {ACL_FIBER_MUTEX*} 鐢<EFBFBD> acl_fiber_mutex_create 鍒涘缓鐨勫崗绋嬩簰鏂ラ攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_mutex_lock(ACL_FIBER_MUTEX* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬩簰鏂ラ攣灏濊瘯鎬ц繘琛屽姞閿侊紝鏃犺鏄惁鎴愬姛鍔犻攣閮戒細绔嬪嵆杩斿洖
|
|
|
|
|
* @param l {ACL_FIBER_MUTEX*} 鐢<EFBFBD> acl_fiber_mutex_create 鍒涘缓鐨勫崗绋嬩簰鏂ラ攣
|
|
|
|
|
* @return {int} 濡傛灉鍔犻攣鎴愬姛鍒欒繑鍥<EFBFBD> 0 鍊硷紝鍚﹀垯杩斿洖 -1
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_mutex_trylock(ACL_FIBER_MUTEX* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍔犻攣鎴愬姛鐨勫崗绋嬭皟鐢ㄦ湰鍑芥暟杩涜瑙i攣锛岃皟鐢ㄦ湰鍑芥暟鐨勫崗绋嬪繀椤绘槸璇ラ攣鐨勫睘涓伙紝鍚﹀垯
|
|
|
|
|
* 鍐呴儴浼氫骇鐢熸柇瑷€
|
|
|
|
|
* @param l {ACL_FIBER_MUTEX*} 鐢<EFBFBD> acl_fiber_mutex_create 鍒涘缓鐨勫崗绋嬩簰鏂ラ攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_mutex_unlock(ACL_FIBER_MUTEX* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓鍗忕▼璇诲啓閿侊紝绾跨▼闈炲畨鍏紝鍙兘鐢ㄥ湪鍚屼竴绾跨▼鍐<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {ACL_FIBER_RWLOCK*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER_RWLOCK* acl_fiber_rwlock_create(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閲婃斁鍗忕▼璇诲啓閿<EFBFBD>
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_rwlock_free(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣鍔犺閿侊紝濡傛灉璇ラ攣褰撳墠姝h鍏跺畠鍗忕▼鍔犱簡璇婚攣锛屽垯鏈崗绋嬩緷鐒跺彲浠<EFBFBD>
|
|
|
|
|
* 姝e父鍔犺閿侊紝濡傛灉璇ラ攣褰撳墠姝h鍏跺畠鍗忕▼鍔犱簡鍐欓攣锛屽垯鏈崗绋嬭繘鍏ラ樆濉炵姸鎬侊紝鐩磋嚦
|
|
|
|
|
* 鍐欓攣閲婃斁
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_rwlock_rlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣灏濊瘯鎬у姞璇婚攣锛屽姞閿佹棤璁烘槸鍚︽垚鍔熼兘浼氱珛鍗宠繑鍥<EFBFBD>
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
|
|
|
|
* @retur {int} 杩斿洖 1 琛ㄧず鍔犻攣鎴愬姛锛岃繑鍥<EFBFBD> 0 琛ㄧず鍔犻攣澶辫触
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_rwlock_tryrlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣鍔犲啓閿侊紝鍙湁褰撹閿佹湭琚换浣曞崗绋嬪姞璇<EFBFBD>/鍐欓攣鏃舵墠浼氳繑鍥烇紝鍚﹀垯闃诲锛<EFBFBD>
|
|
|
|
|
* 鐩磋嚦璇ラ攣鍙姞鍐欓攣
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_rwlock_wlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣灏濊瘯鎬у姞鍐欓攣锛屾棤璁烘槸鍚﹀姞閿佹垚鍔熼兘浼氱珛鍗宠繑鍥<EFBFBD>
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
|
|
|
|
* @return {int} 杩斿洖 1 琛ㄧず鍔犲啓閿佹垚鍔燂紝杩斿洖 0 琛ㄧず鍔犻攣澶辫触
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_rwlock_trywlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣鎴愬姛鍔犺閿佺殑鍗忕▼璋冪敤鏈嚱鏁拌В璇婚攣锛岃皟鐢ㄨ€呭繀椤绘槸涔嬪墠宸叉垚鍔熷姞璇<EFBFBD>
|
|
|
|
|
* 閿佹垚鍔熺殑鍗忕▼
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_rwlock_runlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 瀵瑰崗绋嬭鍐欓攣鎴愬姛鍔犲啓閿佺殑鍗忕▼璋冪敤鏈嚱鏁拌В鍐欓攣锛岃皟鐢ㄨ€呭繀椤绘槸涔嬪墠宸叉垚鍔熷姞鍐<EFBFBD>
|
|
|
|
|
* 閿佹垚鍔熺殑鍗忕▼
|
|
|
|
|
* @param l {ACL_FIBER_RWLOCK*} 鐢<EFBFBD> acl_fiber_rwlock_create 鍒涘缓鐨勮鍐欓攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_rwlock_wunlock(ACL_FIBER_RWLOCK* l);
|
|
|
|
|
|
|
|
|
|
/* fiber_event.c */
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
/* 绾跨▼瀹夊叏鐨勫崗绋嬮攣锛屽彲浠ョ敤鍦ㄤ笉鍚岀嚎绋嬬殑鍗忕▼涔嬮棿鍙婁笉鍚岀嚎绋嬩箣闂寸殑浜掓枼 */
|
2018-11-30 14:38:22 +08:00
|
|
|
|
typedef struct ACL_FIBER_EVENT ACL_FIBER_EVENT;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓鍩轰簬浜嬩欢鐨勫崗绋<EFBFBD>/绾跨▼娣峰悎閿<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {ACL_FIBER_EVENT *}
|
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER_EVENT *acl_fiber_event_create(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閲婃斁浜嬩欢閿<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param {ACL_FIBER_EVENT *}
|
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_event_free(ACL_FIBER_EVENT *event);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 绛夊緟浜嬩欢閿佸彲鐢<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param {ACL_FIBER_EVENT *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @return {int} 杩斿洖 0 琛ㄧず鎴愬姛锛<EFBFBD>-1 琛ㄧず鍑洪敊
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_event_wait(ACL_FIBER_EVENT *event);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 灏濊瘯绛夊緟浜嬩欢閿佸彲鐢<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param {ACL_FIBER_EVENT *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @return {int} 杩斿洖 0 琛ㄧず鎴愬姛锛<EFBFBD>-1 琛ㄧず閿佽鍗犵敤
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_event_trywait(ACL_FIBER_EVENT *event);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浜嬩欢閿佹嫢鏈夎€呴€氱煡绛夊緟鑰呬簨浠堕攣鍙敤锛屽垯绛夊緟鑰呮敹鍒伴€氱煡鍚庡垯鍙幏寰椾簨浠堕攣
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param {ACL_FIBER_EVENT *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @return {int} 杩斿洖 0 琛ㄧず鎴愬姛锛<EFBFBD>-1 琛ㄧず鍑洪敊
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_event_notify(ACL_FIBER_EVENT *event);
|
|
|
|
|
|
|
|
|
|
/* fiber semaphore */
|
|
|
|
|
|
|
|
|
|
typedef struct ACL_FIBER_SEM ACL_FIBER_SEM;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓鍗忕▼淇″彿閲忥紝鍚屾椂鍐呴儴浼氬皢褰撳墠绾跨▼涓庤淇″彿閲忕粦瀹<EFBFBD>
|
|
|
|
|
* @param num {int} 淇″彿閲忓垵濮嬪€硷紙蹇呴』 >= 0锛<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {ACL_FIBER_SEM *}
|
|
|
|
|
*/
|
|
|
|
|
ACL_FIBER_SEM* acl_fiber_sem_create(int num);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閲婃斁鍗忕▼淇″彿閲<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param {ACL_FIBER_SEM *}
|
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_sem_free(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱褰撳墠鍗忕▼淇″彿閲忔墍缁戝畾鐨勭嚎绋<EFBFBD> ID
|
|
|
|
|
* @param sem {ACL_FIBER_SEM*} 鍗忕▼淇″彿閲忓璞<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {acl_pthread_t}
|
|
|
|
|
*/
|
|
|
|
|
acl_pthread_t acl_fiber_sem_get_tid(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 璁剧疆鎸囧畾鍗忕▼淇″彿閲忕殑鐨勭嚎绋<EFBFBD> ID锛屽綋鏀瑰彉鏈崗绋嬩俊鍙烽噺鎵€灞炵殑绾跨▼鏃跺鏋滅瓑寰呯殑鍗忕▼
|
|
|
|
|
* 鏁版嵁闈<EFBFBD> 0 鍒欏唴閮ㄨ嚜鍔<EFBFBD> fatal锛屽嵆褰撳崗绋嬩俊鍙烽噺涓婄瓑寰呭崗绋嬮潪绌烘椂绂佹璋冪敤鏈柟娉<EFBFBD>
|
|
|
|
|
* @param sem {ACL_FIBER_SEM*} 鍗忕▼淇″彿閲忓璞<EFBFBD>
|
|
|
|
|
* @param {acl_pthread_t} 绾跨▼ ID
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_sem_set_tid(ACL_FIBER_SEM* sem, acl_pthread_t tid);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 褰撳崗绋嬩俊鍙烽噺 > 0 鏃朵娇淇″彿閲忓噺 1锛屽惁鍒欑瓑寰呬俊鍙烽噺 > 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param sem {ACL_FIBER_SEM *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @retur {int} 杩斿洖淇″彿閲忓綋鍓嶅€硷紝濡傛灉杩斿洖 -1 琛ㄦ槑褰撳墠绾跨▼涓庡崗绋嬩俊鍙烽噺鎵€灞炵嚎绋<EFBFBD>
|
|
|
|
|
* 涓嶆槸鍚屼竴绾跨▼锛屾鏃惰鏂规硶涓嶇瓑寰呯珛鍗宠繑鍥<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_sem_wait(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 灏濊瘯浣垮崗绋嬩俊鍙烽噺鍑<EFBFBD> 1
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param sem {ACL_FIBER_SEM *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @retur {int} 鎴愬姛鍑<EFBFBD> 1 鏃惰繑鍥炲€<EFBFBD> >= 0锛岃繑鍥<EFBFBD> -1 琛ㄧず褰撳墠淇″彿閲忎笉鍙敤锛屾垨褰撳墠
|
|
|
|
|
* 璋冪敤鑰呯嚎绋嬩笌鍗忕▼淇″彿閲忔墍灞炵嚎绋嬩笉鏄悓涓€绾跨▼
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_sem_trywait(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浣垮崗绋嬩俊鍙烽噺鍔<EFBFBD> 1
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param sem {ACL_FIBER_SEM *}
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* @retur {int} 杩斿洖淇″彿閲忓綋鍓嶅€硷紝杩斿洖 -1 琛ㄧず褰撳墠璋冪敤鑰呯嚎绋嬩笌鍗忕▼淇″彿閲忔墍灞<EFBFBD>
|
|
|
|
|
* 绾跨▼涓嶆槸鍚屼竴绾跨▼
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_sem_post(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鑾峰緱鎸囧畾鍗忕▼淇″彿閲忕殑褰撳墠鍊硷紝璇ュ€煎弽鏄犱簡鐩墠绛夊緟璇ヤ俊鍙烽噺鐨勬暟閲<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @param sem {ACL_FIBER_SEM*}
|
|
|
|
|
* @retur {int}
|
|
|
|
|
*/
|
|
|
|
|
int acl_fiber_sem_num(ACL_FIBER_SEM* sem);
|
|
|
|
|
|
|
|
|
|
/* channel communication */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍗忕▼闂撮€氫俊鐨勭閬<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_CHANNEL ACL_CHANNEL;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍒涘缓鍗忕▼閫氫俊绠¢亾
|
|
|
|
|
* @param elemsize {int} 鍦<EFBFBD> ACL_CHANNEL 杩涜浼犺緭鐨勫璞$殑鍥哄畾灏哄澶у皬锛堝瓧鑺傦級
|
|
|
|
|
* @param bufsize {int} ACL_CHANNEL 鍐呴儴缂撳啿鍖哄ぇ灏忥紝鍗冲彲浠ョ紦瀛<EFBFBD> elemsize 灏哄澶у皬
|
|
|
|
|
* 瀵硅薄鐨勪釜鏁<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {CHANNNEL*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_CHANNEL* acl_channel_create(int elemsize, int bufsize);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 閲婃斁鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勫崗绋嬮€氫俊绠¢亾瀵硅薄
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_channel_free(ACL_CHANNEL* c);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 闃诲寮忓悜鎸囧畾 ACL_CHANNEL 涓彂閫佹寚瀹氱殑瀵硅薄鍦板潃
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 琚彂閫佺殑瀵硅薄鍦板潃
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_send(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 闈為樆濉炲紡鍚戞寚瀹<EFBFBD> ACL_CHANNEL 涓彂閫佹寚瀹氱殑瀵硅薄锛屽唴閮ㄤ細鏍规嵁 acl_channel_create 涓寚瀹<EFBFBD>
|
|
|
|
|
* 鐨<EFBFBD> elemsize 瀵硅薄澶у皬杩涜鏁版嵁鎷疯礉
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 琚彂閫佺殑瀵硅薄鍦板潃
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_send_nb(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 ACL_CHANNEL 涓樆濉炲紡璇诲彇瀵硅薄锛<EFBFBD>
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 瀛樻斁缁撴灉鍐呭
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0 琛ㄧず鎴愬姛璇诲埌鏁版嵁
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_recv(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 ACL_CHANNEL 涓潪闃诲寮忚鍙栧璞★紝鏃犺鏄惁璇诲埌鏁版嵁閮戒細绔嬪嵆杩斿洖
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 瀛樻斁缁撴灉鍐呭
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0 琛ㄧず鎴愬姛璇诲埌鏁版嵁锛屽惁鍒欒〃绀烘湭璇诲埌鏁版嵁
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_recv_nb(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍚戞寚瀹氱殑 ACL_CHANNEL 涓樆濉炲紡鍙戦€佹寚瀹氬璞$殑鍦板潃
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 琚彂閫佸璞$殑鍦板潃
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_sendp(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 CHANNLE 涓樆濉炲紡鎺ユ敹鐢<EFBFBD> acl_channel_sendp 鍙戦€佺殑瀵硅薄鐨勫湴鍧€
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @return {void*} 杩斿洖闈<EFBFBD> NULL锛屾寚瀹氭帴鏀跺埌鐨勫璞$殑鍦板潃
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void* acl_channel_recvp(ACL_CHANNEL* c);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍚戞寚瀹氱殑 ACL_CHANNEL 涓潪闃诲寮忓彂閫佹寚瀹氬璞$殑鍦板潃
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param v {void*} 琚彂閫佸璞$殑鍦板潃
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_sendp_nb(ACL_CHANNEL* c, void* v);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 CHANNLE 涓樆濉炲紡鎺ユ敹鐢<EFBFBD> acl_channel_sendp 鍙戦€佺殑瀵硅薄鐨勫湴鍧€
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @return {void*} 杩斿洖闈<EFBFBD> NULL锛屾寚瀹氭帴鏀跺埌鐨勫璞$殑鍦板潃锛屽鏋滆繑鍥<EFBFBD> NULL 琛ㄧず
|
|
|
|
|
* 娌℃湁璇诲埌浠讳綍瀵硅薄
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void* acl_channel_recvp_nb(ACL_CHANNEL* c);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍚戞寚瀹氱殑 ACL_CHANNEL 涓彂閫佹棤绗﹀彿闀挎暣褰㈡暟鍊<EFBFBD>
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param val {unsigned long} 瑕佸彂閫佺殑鏁板€<EFBFBD>
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_sendul(ACL_CHANNEL* c, unsigned long val);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 ACL_CHANNEL 涓帴鏀舵棤绗﹀彿闀挎暣褰㈡暟鍊<EFBFBD>
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {unsigned long}
|
|
|
|
|
*/
|
|
|
|
|
unsigned long acl_channel_recvul(ACL_CHANNEL* c);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍚戞寚瀹氱殑 ACL_CHANNEL 涓互闈為樆濉炴柟寮忓彂閫佹棤绗﹀彿闀挎暣褰㈡暟鍊<EFBFBD>
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
|
|
|
|
* @param val {unsigned long} 瑕佸彂閫佺殑鏁板€<EFBFBD>
|
|
|
|
|
* @return {int} 杩斿洖鍊<EFBFBD> >= 0
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
int acl_channel_sendul_nb(ACL_CHANNEL* c, unsigned long val);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 浠庢寚瀹氱殑 ACL_CHANNEL 涓互闈為樆濉炴柟寮忔帴鏀舵棤绗﹀彿闀挎暣褰㈡暟鍊<EFBFBD>
|
|
|
|
|
* @param c {ACL_CHANNEL*} 鐢<EFBFBD> acl_channel_create 鍒涘缓鐨勭閬撳璞<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
* @return {unsigned long}
|
|
|
|
|
*/
|
|
|
|
|
unsigned long acl_channel_recvul_nb(ACL_CHANNEL* c);
|
|
|
|
|
|
|
|
|
|
/* master fibers server */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-27 22:44:32 +08:00
|
|
|
|
* 鍩轰簬鍗忕▼鐨勬湇鍔″櫒涓诲嚱鏁板叆鍙o紝璇ユā鍧楀彲浠ュ湪 acl_master 鏈嶅姟鍣ㄦ帶鍒舵鏋朵笅杩愯
|
|
|
|
|
* @param argc {int} 浣跨敤鑰呬紶鍏ョ殑鍙傛暟鏁扮粍 argv 鐨勫ぇ灏<EFBFBD>
|
|
|
|
|
* @param argv {char*[]} 鍙傛暟鏁扮粍澶у皬
|
|
|
|
|
* @param service {void (*)(ACL_VSTREAM*, void*)} 鎺ユ敹鍒颁竴涓柊瀹㈡埛绔繛鎺ヨ姹<EFBFBD>
|
|
|
|
|
* 鍚庡垱寤轰竴涓崗绋嬪洖璋冩湰鍑芥暟
|
|
|
|
|
* @param ctx {void*} service 鍥炶皟鍑芥暟鐨勭浜屼釜鍙傛暟
|
|
|
|
|
* @param name {int} 鎺у埗鍙傛暟鍒楄〃涓殑绗竴涓帶鍒跺弬鏁<EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void acl_fiber_server_main(int argc, char* argv[],
|
|
|
|
|
void (*service)(void*, ACL_VSTREAM*), void* ctx, int name, ...);
|
|
|
|
|
const char* acl_fiber_server_conf(void);
|
|
|
|
|
|
|
|
|
|
void acl_fiber_chat_main(int argc, char* argv[],
|
|
|
|
|
int (*service)(ACL_VSTREAM*, void*), void* ctx, int name, ...);
|
|
|
|
|
|
|
|
|
|
/**************************** fiber iostuff *********************************/
|
|
|
|
|
|
|
|
|
|
ssize_t fiber_read(int fd, void* buf, size_t count);
|
|
|
|
|
ssize_t fiber_readv(int fd, const struct iovec* iov, int iovcnt);
|
|
|
|
|
ssize_t fiber_recv(int sockfd, void* buf, size_t len, int flags);
|
|
|
|
|
ssize_t fiber_recvfrom(int sockfd, void* buf, size_t len, int flags,
|
|
|
|
|
struct sockaddr* src_addr, socklen_t* addrlen);
|
|
|
|
|
ssize_t fiber_recvmsg(int sockfd, struct msghdr* msg, int flags);
|
|
|
|
|
|
|
|
|
|
ssize_t fiber_write(int fd, const void* buf, size_t count);
|
|
|
|
|
ssize_t fiber_writev(int fd, const struct iovec* iov, int iovcnt);
|
|
|
|
|
ssize_t fiber_send(int sockfd, const void* buf, size_t len, int flags);
|
|
|
|
|
ssize_t fiber_sendto(int sockfd, const void* buf, size_t len, int flags,
|
|
|
|
|
const struct sockaddr* dest_addr, socklen_t addrlen);
|
|
|
|
|
ssize_t fiber_sendmsg(int sockfd, const struct msghdr* msg, int flags);
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|