mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-16 01:40:52 +08:00
9697f95b8f
This reverts commit 15d999759e
.
372 lines
13 KiB
C
372 lines
13 KiB
C
#ifndef ACL_EVENTS_H_INCLUDED
|
||
#define ACL_EVENTS_H_INCLUDED
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#include "../stdlib/acl_define.h"
|
||
#include <time.h>
|
||
#include "../stdlib/acl_vstream.h"
|
||
#include "acl_timer.h"
|
||
|
||
/*+++++++++++++++++++++++++++ È«¾Öºê¶¨Òå +++++++++++++++++++++++++++++++++++*/
|
||
/* Event codes. */
|
||
#define ACL_EVENT_READ (1 << 0) /**< read event */
|
||
#define ACL_EVENT_ACCEPT (1 << 1) /**< accept one connection */
|
||
#define ACL_EVENT_WRITE (1 << 2) /**< write event */
|
||
#define ACL_EVENT_CONNECT (1 << 3) /**< client has connected the server*/
|
||
#define ACL_EVENT_XCPT (1 << 4) /**< exception */
|
||
#define ACL_EVENT_TIME (1 << 5) /**< timer event */
|
||
#define ACL_EVENT_RW_TIMEOUT (1 << 6) /**< read/write timeout event */
|
||
#define ACL_EVENT_TIMEOUT ACL_EVENT_RW_TIMEOUT
|
||
|
||
#define ACL_EVENT_FD_IDLE 0
|
||
#define ACL_EVENT_FD_BUSY 1
|
||
|
||
#define ACL_EVENT_ERROR ACL_EVENT_XCPT
|
||
|
||
#define ACL_EVENT_SELECT 0
|
||
#define ACL_EVENT_POLL 1
|
||
#define ACL_EVENT_KERNEL 2
|
||
#define ACL_EVENT_WMSG 3
|
||
|
||
/*
|
||
* Dummies.
|
||
*/
|
||
#define ACL_EVENT_NULL_TYPE 0
|
||
#define ACL_EVENT_NULL_CONTEXT ((char *) 0)
|
||
|
||
|
||
/* in acl_events.c */
|
||
/*
|
||
* Timer events. Timer requests are kept sorted, in a circular list. We use
|
||
* the RING abstraction, so we get to use a couple ugly macros.
|
||
*/
|
||
typedef struct ACL_EVENT_TIMER ACL_EVENT_TIMER;
|
||
|
||
typedef struct ACL_EVENT ACL_EVENT;
|
||
typedef struct ACL_EVENT_FDTABLE ACL_EVENT_FDTABLE;
|
||
|
||
/*
|
||
* External interface.
|
||
*/
|
||
#if 0
|
||
typedef void (*ACL_EVENT_NOTIFY_FN) (int event_type, void *context);
|
||
typedef ACL_EVENT_NOTIFY_FN ACL_EVENT_NOTIFY_RDWR;
|
||
typedef ACL_EVENT_NOTIFY_FN ACL_EVENT_NOTIFY_TIME;
|
||
#else
|
||
typedef void (*ACL_EVENT_NOTIFY_RDWR)(int event_type, ACL_EVENT *event,
|
||
ACL_VSTREAM *stream, void *context);
|
||
typedef void (*ACL_EVENT_NOTIFY_TIME)(int event_type, ACL_EVENT *event,
|
||
void *context);
|
||
#endif
|
||
|
||
/*----------------------------------------------------------------------------*/
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öʼþÑ»·¶ÔÏóµÄ×ÜÈë¿Ú£¬´Ëº¯Êý»á¸ù¾ÝÓû§²ÎÊýµÄ²»Í¬×Ô¶¯µ÷ÓÃÏÂÃæµÄʼþ¶ÔÏó´´½¨º¯Êý
|
||
* @param event_mode {int} ʼþ´¦Àí·½Ê½£¬Ä¿Ç°½öÖ§³Ö: ACL_EVENT_SELECT, ACL_EVENT_KERNEL,
|
||
* ACL_EVENT_POLL, ACL_EVENT_WMSG
|
||
* @param use_thr {int} ÊÇ·ñ²ÉÓÃÏß³Ìʼþ·½Ê½£¬·Ç0±íʾ°´Ïß³Ìʼþ·½Ê½
|
||
* @param delay_sec {int} ʼþÑ»·µÈ´ýʱµÄ×ÃëÊý£¬µ± event_mode Ϊ ACL_EVENT_WMSG
|
||
* ʱ£¬ÇÒ¸ÃÖµ´óÓÚ 0 ʱ£¬Ôò¸ÃÖµ±»µ±×÷ÏûÏ¢Öµ¶Ô´ý´«¸ø acl_event_new_wmsg£¬ÓÃÀ´ÓëÒì
|
||
* ²½ÏûÏ¢¾ä±ú°ó¶¨
|
||
* @param delay_usec {int} ʼþÑ»·µÈ´ýʱµÄ×΢ÃëÊý(½ö select ·½Ê½ÓÐÓÃ)
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new(int event_mode, int use_thr,
|
||
int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öеÄʼþ¶ÔÏó, ¸Ãʼþ²»Ö§³Ö¶àÏß³Ì
|
||
* @param delay_sec {int} ÔÚµ÷Óà select() º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷Óà select() º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_select(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öеÄʼþ¶ÔÏó, ¸ÃʼþÖ§³ÖÏß³Ìģʽ
|
||
* @param delay_sec {int} ÔÚµ÷Óà select() º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷Óà select() º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_select_thr(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öÖ§³Ö poll µÄʼþ¶ÔÏ󣬲»Ö§³Ö¶àÏß³Ì
|
||
* @param delay_sec {int} ÔÚµ÷Óà poll() º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷Óà poll() º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_poll(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öÖ§³Ö poll µÄʼþ¶ÔÏó£¬Ö§³Ö¶àÏß³Ì
|
||
* @param delay_sec {int} ÔÚµ÷Óà poll() º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷Óà poll() º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_poll_thr(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öеÄʼþ¶ÔÏó, ¸Ãʼþ²ÉÓÃЧÂÊ¸ßµÄ epoll/devpoll/kqueue ·½Ê½£¬ÇÒ²»Ö§³Ö¶àÏß³Ì
|
||
* @param delay_sec {int} ÔÚµ÷ÓÃʼþÑ»·º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷ÓÃʼþÑ»·º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý(ºöÂÔ²»¼Æ)
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_kernel(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öеÄʼþ¶ÔÏó, ¸Ãʼþ²ÉÓÃЧÂÊ¸ßµÄ epoll/devpoll/kqueue ·½Ê½£¬ÇÒ²ÉÓÃÏ̷߳½Ê½
|
||
* @param delay_sec {int} ÔÚµ÷ÓÃʼþÑ»·º¯ÊýʱÐÝÏ¢µÄÃëÊý
|
||
* @param delay_usec {int} ÔÚµ÷ÓÃʼþÑ»·º¯ÊýʱÐÝÏ¢µÄ΢ÃëÊý(ºöÂÔ²»¼Æ)
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_kernel_thr(int delay_sec, int delay_usec);
|
||
|
||
/**
|
||
* ´´½¨Ò»¸öÄÜÓë Windows ½çÃæÏûÏ¢°óÔÚÒ»ÆðµÄʼþÒýÇæ¶ÔÏó
|
||
* @param nMsg {unsigned int} Èç¹û¸ÃÖµ´óÓÚ 0 Ôò½«¸ÃÒì²½¾ä±úÓë¸ÃÏûÏ¢Öµ°ó¶¨£¬
|
||
* ·ñÔò½«¸ÃÒì²½¾ä±úÓëȱʡµÄÏûÏ¢Öµ°ó¶¨
|
||
* @return {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õ룬Èç¹ûΪ¿Õ±íʾ³ö´í
|
||
*/
|
||
ACL_API ACL_EVENT *acl_event_new_wmsg(unsigned int nMsg);
|
||
|
||
#if defined (_WIN32) || defined(_WIN64)
|
||
ACL_API HWND acl_event_wmsg_hwnd(ACL_EVENT *eventp);
|
||
#endif
|
||
|
||
/**
|
||
* ΪÁË·ÀÖ¹ÔÚ¶àÏß³ÌģʽÏ select µÈʼþÑ»·µÄʱ¼äµÈ´ý£¬¿ÉÒÔÌí¼Ó´ËÏîÒÔÖжϵȴý£¬
|
||
* ¼Ó¿ìʼþÑ»·¹ý³Ì
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
*/
|
||
ACL_API void acl_event_add_dog(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ÉèÖÃʼþ´¥·¢µÄÇ°ÖúͺóÖô¦Àí¹ý³Ì
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param fire_begin {void (*)(ACL_EVENT*, void*)} µ±Ê¼þ±»Í³Ò»´¥·¢Ç°µÄ»Øµ÷¹ý³Ì
|
||
* @param fire_end {void (*)(ACL_EVENT*, void*)} µ±Ê¼þ±»Í³Ò»´¥·¢ºóµÄ»Øµ÷¹ý³Ì
|
||
* @param ctx {void*} fire_begin / fire_end µÄµÚ¶þ¸ö²ÎÊý
|
||
*/
|
||
ACL_API void acl_event_set_fire_hook(ACL_EVENT *eventp,
|
||
void (*fire_begin)(ACL_EVENT*, void*),
|
||
void (*fire_end)(ACL_EVENT*, void*),
|
||
void* ctx);
|
||
|
||
/**
|
||
* ÉèÖÃʼþÑ»·¹ý³ÌÖж¨Ê±¼ì²éËùÓÐÃèÊö×Ö״̬µÄʱ¼ä¼ä¸ô£¬ÄÚ²¿È±Ê¡ÖµÎª 100 ms
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param n {int} ¶¨Ê±²é¼ìʱ¼ä¼ä¸ô (ºÁÃ뼶)
|
||
*/
|
||
ACL_API void acl_event_set_check_inter(ACL_EVENT *eventp, int n);
|
||
|
||
/**
|
||
* ÊÍ·Åʼþ½á¹¹
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
*/
|
||
ACL_API void acl_event_free(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ·µ»ØʼþµÄʱ¼ä½Ø
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {acl_int64} µ±Ç°Ê¼þµÄʱ¼ä½Ø(΢Ã뼶±ð)
|
||
*/
|
||
ACL_API acl_int64 acl_event_time(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ½«Ê¼þÖеÄËùÓÐÈÎÎñÖ´ÐÐÍê±Ï
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
*/
|
||
ACL_API void acl_event_drain(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ÉèÖÃÊý¾ÝÁ÷¿É¶Áʱ(Ö¸ÓÐÊý¾Ý´ý¶Á»òÃèÊö·û³ö´í»òÃèÊö·û¹Ø±Õ)µÄ»Øµ÷º¯Êý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
* @param read_timeout {int} ¶Á³¬Ê±Ê±¼ä(Ãë)
|
||
* @param callback {ACL_EVENT_NOTIFY_RDWR} Êý¾ÝÁ÷¿É¶ÁʱµÄ»Øµ÷º¯Êý
|
||
* @param context {void*} »Øµ÷º¯Êý callback ËùÐèÒªµÄ²ÎÊý
|
||
*/
|
||
ACL_API void acl_event_enable_read(ACL_EVENT *eventp, ACL_VSTREAM *stream,
|
||
int read_timeout, ACL_EVENT_NOTIFY_RDWR callback, void *context);
|
||
|
||
/**
|
||
* ÉèÖÃÊý¾ÝÁ÷¿Éдʱ(Ö¸Óпռä¿ÉÒÔд»òÃèÊö·û³ö´í»òÃèÊö·û¹Ø±Õ)µÄ»Øµ÷º¯Êý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
* @param write_timeout {int} д³¬Ê±Ê±¼ä(Ãë)
|
||
* @param callback {ACL_EVENT_NOTIFY_RDWR} Êý¾ÝÁ÷¿ÉдʱµÄ»Øµ÷º¯Êý
|
||
* @param context {void*} »Øµ÷º¯Êý callback ËùÐèÒªµÄ²ÎÊý
|
||
*/
|
||
ACL_API void acl_event_enable_write(ACL_EVENT *eventp, ACL_VSTREAM *stream,
|
||
int write_timeout, ACL_EVENT_NOTIFY_RDWR callback, void *context);
|
||
|
||
/**
|
||
* ÉèÖüàÌýÌ×½Ó¿Ú(Ö¸ÓÐÐÂÁ¬½Óµ½´ï/±»ÏµÍ³ÖжÏ/³ö´íʱ)µÄ»Øµ÷º¯Êý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
* @param read_timeout {int} ¼àÌý³¬Ê±Ê±¼ä(Ãë)£¬¿ÉÒÔΪ0
|
||
* @param callback {ACL_EVENT_NOTIFY_RDWR} Êý¾ÝÁ÷¿É¶ÁʱµÄ»Øµ÷º¯Êý
|
||
* @param context {void*} »Øµ÷º¯Êý callback ËùÐèÒªµÄ²ÎÊý
|
||
*/
|
||
ACL_API void acl_event_enable_listen(ACL_EVENT *eventp, ACL_VSTREAM *stream,
|
||
int read_timeout, ACL_EVENT_NOTIFY_RDWR callback, void *context);
|
||
|
||
/**
|
||
* ½«Êý¾ÝÁ÷´ÓʼþµÄ¶Á¼àÌýÁ÷¼¯ºÏÖÐÇå³ý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API void acl_event_disable_read(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ½«Êý¾ÝÁ÷´ÓʼþµÄд¼àÌýÁ÷¼¯ºÏÖÐÇå³ý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API void acl_event_disable_write(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ½«Êý¾ÝÁ÷´ÓʼþµÄ¶Áд¼àÌýÁ÷¼¯ºÏÖÐÇå³ý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API void acl_event_disable_readwrite(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ¼ì²éÁ÷ÖеÄÃèÊö·ûÊÇ·ñÒѾÖÃÈë¶Á¡¢Ð´»òÒ쳣ʼþµÄ¼¯ºÏÖÐ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API int acl_event_isset(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ¼ì²éÁ÷ÖеÄÃèÊö·ûÊÇ·ñÒѾÖÃÈë¶ÁʼþµÄ¼¯ºÏÖÐ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API int acl_event_isrset(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ¼ì²éÁ÷ÖеÄÃèÊö·ûÊÇ·ñÒѾÖÃÈëдʼþµÄ¼¯ºÏÖÐ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API int acl_event_iswset(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* ¼ì²éÁ÷ÖеÄÃèÊö·ûÊÇ·ñÒѾÖÃÈëÒ쳣ʼþµÄ¼¯ºÏÖÐ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param stream {ACL_VSTREAM*} Êý¾ÝÁ÷Ö¸Õë, ²»ÄÜΪ¿Õ, ÇÒÆäÖеÄÃèÊö·û±ØÐëÊÇÓÐЧµÄ
|
||
*/
|
||
ACL_API int acl_event_isxset(ACL_EVENT *eventp, ACL_VSTREAM *stream);
|
||
|
||
/**
|
||
* Ìí¼ÓÒ»¸ö¶¨Ê±Ê¼þ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param callback {ACL_EVENT_NOTIFY_TIME} ¶¨Ê±Ê¼þµÄ»Øµ÷º¯Êý
|
||
* @param context {void*} callback ËùÐèÒªµÄ»Øµ÷²ÎÊý
|
||
* @param delay {acl_int64} eventp->event_present + delay Ϊ¸Ãʼþº¯Êý¿ªÊ¼Ö´ÐеÄʱ¼ä
|
||
* µ¥Î»ÎªÎ¢Ãë
|
||
* @param keep {int} ÊÇ·ñÖظ´¶¨Ê±Æ÷ÈÎÎñ
|
||
* @return {acl_int64} ʼþÖ´ÐеÄʱ¼ä½Ø£¬µ¥Î»ÎªÎ¢Ãë
|
||
*/
|
||
ACL_API acl_int64 acl_event_request_timer(ACL_EVENT *eventp,
|
||
ACL_EVENT_NOTIFY_TIME callback, void *context, acl_int64 delay, int keep);
|
||
|
||
/**
|
||
* È¡ÏûÒ»¸ö¶¨Ê±Ê¼þ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param callback {ACL_EVENT_NOTIFY_TIME} ¶¨Ê±Ê¼þµÄ»Øµ÷º¯Êý
|
||
* @param context {void*} callback ËùÐèÒªµÄ»Øµ÷²ÎÊý
|
||
* @return acl_int64 {acl_int64} ¾àÀ뿪ʼִÐÐʼþº¯ÊýµÄʱ¼ä¼ä¸ô, ÒÔ΢ÃëΪµ¥Î»
|
||
*/
|
||
ACL_API acl_int64 acl_event_cancel_timer(ACL_EVENT *eventp,
|
||
ACL_EVENT_NOTIFY_TIME callback, void *context);
|
||
|
||
/**
|
||
* µ±¶¨Ê±Æ÷´¦ÀíÍê±Ïºó£¬ÊÇ·ñÐèÒªÔÙ´ÎÉèÖøö¨Ê±Æ÷£¬ÒÔ·½±ãµ÷ÓÃÕßÑ»·
|
||
* ʹÓøö¨Ê±Æ÷
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param callback {ACL_EVENT_NOTIFY_TIME} ·Ç¿Õ
|
||
* @param context {void*} ¸½ÊôÓÚ callback µÄ±äÁ¿
|
||
* @param onoff {int} ÊÇ·ñÖظ´Í¨¹ý acl_event_request_timer ÉèÖõĶ¨Ê±Æ÷
|
||
*/
|
||
ACL_API void acl_event_keep_timer(ACL_EVENT *eventp, ACL_EVENT_NOTIFY_TIME callback,
|
||
void *context, int onoff);
|
||
|
||
/**
|
||
* ÅжÏËùÉèÖõĶ¨Ê±Æ÷¶¼´¦ÓÚÖظ´Ê¹ÓÃ״̬
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param callback {ACL_EVENT_NOTIFY_TIME} ·Ç¿Õ
|
||
* @param context {void*} ¸½ÊôÓÚ callback µÄ±äÁ¿
|
||
* @return {int} !0 ±íʾËùÉèÖõĶ¨Ê±Æ÷¶¼´¦ÓÚÖظ´Ê¹ÓÃ״̬
|
||
*/
|
||
ACL_API int acl_event_timer_ifkeep(ACL_EVENT *eventp, ACL_EVENT_NOTIFY_TIME callback,
|
||
void *context);
|
||
|
||
/**
|
||
* ʼþÑ»·Ö´Ðеĵ÷¶Èº¯Êý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
*/
|
||
ACL_API void acl_event_loop(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ÉèÖÃʼþÑ»·µÄ¿ÕÏÐÐÝϢʱ¼äÖеÄÃ뼶ÊýÖµ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param sec {int} Ã뼶¿ÕÏÐÐÝϢʱ¼äÖµ
|
||
*/
|
||
ACL_API void acl_event_set_delay_sec(ACL_EVENT *eventp, int sec);
|
||
|
||
/**
|
||
* ÉèÖÃʼþÑ»·µÄ¿ÕÏÐÐÝϢʱ¼äÖеÄ΢Ã뼶ÊýÖµ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @param usec {int} ΢Ã뼶¿ÕÏÐÐÝϢʱ¼äÖµ
|
||
*/
|
||
ACL_API void acl_event_set_delay_usec(ACL_EVENT *eventp, int usec);
|
||
|
||
/**
|
||
* »ñµÃʼþÑ»·µÄ¿ÕÏÐÐÝϢʱ¼äÖеÄÃ뼶ÊýÖµ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {int} Ã뼶¿ÕÏÐÐÝϢʱ¼äÖµ
|
||
*/
|
||
ACL_API int acl_event_get_delay_sec(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* »ñµÃʼþÑ»·µÄ¿ÕÏÐÐÝϢʱ¼äÖеÄ΢Ã뼶ÊýÖµ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {int} ΢Ã뼶¿ÕÏÐÐÝϢʱ¼äÖµ
|
||
*/
|
||
ACL_API int acl_event_get_delay_usec(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* ÊÇ·ñ²ÉÓÃÏß³Ìʼþ·½Ê½
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {int} 0: ·ñ; !=0: ÊÇ
|
||
*/
|
||
ACL_API int acl_event_use_thread(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* »ñµÃµ±Ç°Ê¼þÒýÇæµÄʼþÄ£ÐÍ
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {int} ACL_EVENT_SELECT/ACL_EVENT_KERNEL/ACL_EVENT_POLL
|
||
*/
|
||
ACL_API int acl_event_mode(ACL_EVENT *eventp);
|
||
|
||
/**
|
||
* »ñµÃ±¾´ÎʼþÑ»·ºó±»´¥·¢µÄ IO ʼþµÄ´ÎÊý
|
||
* @param eventp {ACL_EVENT*} ʼþ¶ÔÏóÖ¸Õë, ²»ÎªÄÜΪ¿Õ
|
||
* @return {int} ¸ÃֵΪ±¾´ÎÑ»·±»´¥·¢µÄʼþ´ÎÊý
|
||
*/
|
||
ACL_API int acl_event_last_nready(ACL_EVENT *eventp);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif
|