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

77 lines
1.3 KiB
C++
Raw Normal View History

2014-11-19 00:25:21 +08:00
#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
namespace acl
{
class connect_pool;
class ACL_CPP_API connect_client
{
public:
connect_client() : when_(0), pool_(NULL) {}
virtual ~connect_client() {}
/**
* <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>α<EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {time_t}
*/
time_t get_when()
{
return when_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void set_when(time_t when)
{
when_ = when;
}
/**
* <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>
*/
virtual bool open() = 0;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD> connect_pool <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> set_pool <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {connect_pool*}
*/
connect_pool* get_pool() const
{
return pool_;
}
public:
/**
* <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> 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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param rw_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
*/
virtual void set_timeout(int conn_timeout, int rw_timeout)
{
conn_timeout_ = conn_timeout;
rw_timeout_ = rw_timeout;
}
protected:
int conn_timeout_;
int rw_timeout_;
2014-11-19 00:25:21 +08:00
friend class connect_pool;
time_t when_;
connect_pool* pool_;
void set_pool(connect_pool* pool)
{
pool_ = pool;
}
};
} // namespace acl