acl/lib_acl_cpp/include/acl_cpp/db/db_pool.hpp

73 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
2014-11-19 00:25:21 +08:00
#include <list>
2017-06-02 14:47:24 +08:00
#include "../db/db_handle.hpp"
#include "../connpool/connect_pool.hpp"
2014-11-19 00:25:21 +08:00
#if !defined(ACL_DB_DISABLE)
2014-11-19 00:25:21 +08:00
namespace acl {
class db_handle;
class locker;
2015-08-12 16:48:24 +08:00
class ACL_CPP_API db_pool : public connect_pool
2014-11-19 00:25:21 +08:00
{
public:
/**
*
* @param dbaddr {const char*}
* @param count {size_t}
* @param idx {size_t} ( 0 )
2014-11-19 00:25:21 +08:00
*/
db_pool(const char* dbaddr, size_t count, size_t idx = 0);
2015-08-12 16:48:24 +08:00
virtual ~db_pool() {};
2014-11-19 00:25:21 +08:00
/**
*
* db_handle::open
* db_pool->put(db_handle*)
* delete
* @return {db_handle*}
2014-11-19 00:25:21 +08:00
*/
db_handle* peek_open();
2014-11-19 00:25:21 +08:00
/**
*
* @return {size_t}
2014-11-19 00:25:21 +08:00
*/
size_t get_dblimit() const
2014-11-19 00:25:21 +08:00
{
2015-08-12 16:48:24 +08:00
return get_max();
2014-11-19 00:25:21 +08:00
}
/**
*
* @return {size_t}
2014-11-19 00:25:21 +08:00
*/
size_t get_dbcount() const
2014-11-19 00:25:21 +08:00
{
2015-08-12 16:48:24 +08:00
return get_count();
2014-11-19 00:25:21 +08:00
}
2015-08-12 16:48:24 +08:00
2014-11-19 00:25:21 +08:00
/**
* ()
* @param ttl {int} ()
2014-11-19 00:25:21 +08:00
*/
2015-08-12 16:48:24 +08:00
void set_idle(int ttl)
{
set_idle_ttl(ttl);
}
2014-11-19 00:25:21 +08:00
};
class ACL_CPP_API db_guard : public connect_guard
{
public:
db_guard(db_pool& pool) : connect_guard(pool) {}
~db_guard(void);
};
2014-11-19 00:25:21 +08:00
} // namespace acl
#endif // !defined(ACL_DB_DISABLE)