acl/lib_acl_cpp/include/acl_cpp/connpool/check_client.hpp

93 lines
1.7 KiB
C++
Raw Normal View History

2015-04-04 15:25:29 +08:00
#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
2015-04-04 15:25:29 +08:00
#include <map>
#include <vector>
#if !defined(_WIN32) && !defined(_WIN64)
2015-05-21 21:49:35 +08:00
#include <sys/time.h>
#endif
2017-06-02 14:47:24 +08:00
#include "../stream/aio_socket_stream.hpp"
#include "../stdlib/string.hpp"
2015-04-04 15:25:29 +08:00
namespace acl
{
class check_timer;
class aio_socket_stream;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class ACL_CPP_API check_client : public aio_open_callback
{
public:
check_client(check_timer& timer, const char* addr,
aio_socket_stream& conn, struct timeval& begin);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {aio_socket_stream&}
*/
aio_socket_stream& get_conn() const
{
return conn_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>ַ
* @return {const char*}
*/
const char* get_addr() const
{
return addr_.c_str();
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param yesno {bool}
*/
void set_alive(bool yesno);
/**
* <EFBFBD>رշ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void close();
public:
// <20><><EFBFBD>µĺ<C2B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD><CAB9>
/**
* <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
* @return {bool}
*/
bool blocked() const
{
return blocked_;
}
/**
* <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> close <EFBFBD><EFBFBD><EFBFBD>رյ<EFBFBD>
* @param on {bool} <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>״̬
*/
void set_blocked(bool on);
private:
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
bool open_callback();
void close_callback();
bool timeout_callback();
private:
~check_client() {}
private:
bool blocked_;
bool aliving_;
bool timedout_;
2015-04-04 15:25:29 +08:00
struct timeval begin_;
check_timer& timer_;
aio_socket_stream& conn_;
string addr_;
};
} // namespace acl