2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
|
|
|
|
#include "../stdlib/noncopyable.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
struct ACL_AIO;
|
|
|
|
|
struct ACL_EVENT;
|
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
ENGINE_SELECT, // select ģʽ(֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ̨)
|
|
|
|
|
ENGINE_POLL, // poll ģʽ(<28><> UNIX ƽ̨)
|
|
|
|
|
ENGINE_KERNEL, // kernel ģʽ(win32: iocp, Linux: epoll, FreeBsd: kqueue, Solaris: devpoll
|
|
|
|
|
ENGINE_WINMSG // win32 GUI <20><>Ϣģʽ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} aio_handle_type;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD> select/poll/epoll/kqueue/devpoll/iocp,
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class aio_timer_callback;
|
|
|
|
|
class aio_delay_free;
|
|
|
|
|
class aio_timer_delay_free;
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API aio_handle : private noncopyable
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>棬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
* @param engine_type {aio_handle_type} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ENGINE_SELECT: select <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD> win32/unix ƽ̨
|
|
|
|
|
* ENGINE_POLL: poll <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD> unix ƽ̨
|
|
|
|
|
* ENGINE_KERNEL: <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>ϵͳƽ̨<EFBFBD><EFBFBD>֧<EFBFBD>ֵĸ<EFBFBD>Ч<EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ENGINE_WINMSG: win32 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD> win32 ƽ̨
|
|
|
|
|
* @param nMsg {unsigned int} <EFBFBD><EFBFBD> engine_type Ϊ ENGINE_WINMSG<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱʡ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD> engine_type Ϊ<EFBFBD><EFBFBD> ENGINE_WINMSG ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
aio_handle(aio_handle_type engine_type = ENGINE_SELECT,
|
|
|
|
|
unsigned int nMsg = 0);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD> ACL_AIO <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>Զ<EFBFBD><EFBFBD>ͷŸ<EFBFBD> ACL_AIO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param handle {ACL_AIO*} ACL_AIO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
aio_handle(ACL_AIO* handle);
|
|
|
|
|
|
2019-07-07 11:00:12 +08:00
|
|
|
|
virtual ~aio_handle(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><EFBFBD><EFBFBD>еĻ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳У<EFBFBD>һ<EFBFBD><EFBFBD> aio_handle <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱʡ
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param onoff {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
void keep_read(bool onoff);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĹ<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
bool keep_read(void) const;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param callback {aio_timer_callback*} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param delay {int64} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
|
|
|
|
|
* @param id {unsigned int} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int64} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>1970.1.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 set_timer(aio_timer_callback* callback,
|
|
|
|
|
__int64 delay, unsigned int id = 0);
|
|
|
|
|
#else
|
|
|
|
|
long long int set_timer(aio_timer_callback* callback,
|
|
|
|
|
long long int delay, unsigned int id = 0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
* @param callback {aio_timer_callback*} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {time_t} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>1970.1.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 del_timer(aio_timer_callback* callback);
|
|
|
|
|
#else
|
|
|
|
|
long long int del_timer(aio_timer_callback* callback);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> ID <EFBFBD>ŵĶ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param callback {aio_timer_callback*} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param id {unsigned int} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD>
|
|
|
|
|
* @return {time_t} <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>1970.1.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 del_timer(aio_timer_callback* callback, unsigned int id);
|
|
|
|
|
#else
|
|
|
|
|
long long del_timer(aio_timer_callback* callback, unsigned int id);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʱ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ͷŸö<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й¶<EFBFBD><EFBFBD>
|
|
|
|
|
* ͨ<EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʱ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> aio_delay_free::destroy())<EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ڴ<EFBFBD>й¶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param callback {aio_delay_free*}
|
|
|
|
|
*/
|
|
|
|
|
void delay_free(aio_delay_free* callback);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_AIO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {ACL_AIO*}
|
|
|
|
|
*/
|
|
|
|
|
ACL_AIO* get_handle(void) const;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {aio_handle_type}
|
|
|
|
|
*/
|
|
|
|
|
aio_handle_type get_engine_type(void) const;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
int length(void) const;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD>Ƿ<EFBFBD>Ӧ<EFBFBD><EFBFBD>ֹ<EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
bool check(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2018-01-09 23:45:13 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-01-09 23:45:13 +08:00
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
int last_nready(void) const;
|
2018-01-09 23:45:13 +08:00
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ֪ͨ<EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
void stop(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>״̬
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
void reset(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-06-05 17:48:52 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> DNS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip1:port1;ip2:port2...
|
|
|
|
|
* @param addrs {const char*} DNS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>磺8.8.8.8:53
|
|
|
|
|
* @param timeout {int} DNS <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ʱʱ<EFBFBD>䣨<EFBFBD>룩
|
2019-06-05 17:48:52 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_dns(const char* addrs, int timeout);
|
|
|
|
|
|
2015-12-20 15:27:55 +08:00
|
|
|
|
public:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>ĵȴ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>뼶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> select/poll/epoll/kqueue/devpoll
|
|
|
|
|
* ʱ<EFBFBD><EFBFBD><EFBFBD>뼶<EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
2015-12-20 15:27:55 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_delay_sec(int n);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>ĵȴ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>뼶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> select/poll/epoll/kqueue/devpoll
|
|
|
|
|
* ʱ<EFBFBD><EFBFBD><EFBFBD>뼶<EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
2015-12-20 15:27:55 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_delay_usec(int n);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ڲ<EFBFBD>ȱʡֵ 100 ms
|
2015-12-20 15:27:55 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_check_inter(int n);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param n {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
2015-12-20 15:27:55 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_rbuf_size(int n);
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
protected:
|
|
|
|
|
friend class aio_stream;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
void increase(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
virtual void on_increase(void) {}
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
void decrease(void);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-07 11:00:12 +08:00
|
|
|
|
virtual void on_decrease(void) {}
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ACL_AIO* aio_;
|
|
|
|
|
bool inner_alloc_;
|
|
|
|
|
bool stop_;
|
|
|
|
|
int nstream_;
|
|
|
|
|
aio_handle_type engine_type_;
|
|
|
|
|
aio_timer_delay_free* delay_free_timer_;
|
|
|
|
|
|
|
|
|
|
void destroy_timer(aio_timer_callback* callback);
|
|
|
|
|
static void on_timer_callback(int event_type, ACL_EVENT*,
|
|
|
|
|
aio_timer_callback *callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|