acl/lib_acl_cpp/include/acl_cpp/hsocket/hspool.hpp

61 lines
1.7 KiB
C++
Raw Normal View History

#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
#include <list>
#ifndef ACL_CLIENT_ONLY
2014-11-19 00:25:21 +08:00
struct ACL_HTABLE;
namespace acl {
class hsclient;
class locker;
class ACL_CPP_API hspool : public noncopyable
2014-11-19 00:25:21 +08:00
{
public:
/**
*
* @param addr_rw {const char*} handlersocket Mysql
* ip:port handlersocket
* @param addr_rd {const char*} handlersocket Mysql
* ip:port handlersocket
* @param cache_enable {bool}
* @param retry_enable {bool}
2014-11-19 00:25:21 +08:00
*/
hspool(const char* addr_rw, const char* addr_rd = NULL,
bool cache_enable = true, bool retry_enable = true);
~hspool();
/**
*
* @param dbn {const char*}
* @param tbl {const char*}
* @param idx {const char*}
* @param flds {const char*}
* ",; \t" user_id,user_name,user_mail
* @param readonly {bool}
2014-11-19 00:25:21 +08:00
*/
hsclient* peek(const char* dbn, const char* tbl,
const char* idx, const char* flds, bool readonly = false);
/**
*
2014-11-19 00:25:21 +08:00
* @param client {hsclient*}
*/
void put(hsclient* client);
private:
char* addr_rw_;
char* addr_rd_;
bool cache_enable_;
bool retry_enable_;
std::list<hsclient*> pool_;
locker* locker_;
};
} // namespace acl
#endif // ACL_CLIENT_ONLY