28 #if !defined(MYSQLPP_CPOOL_H)
29 #define MYSQLPP_CPOOL_H
40 #if !defined(DOXYGEN_IGNORE)
42 class MYSQLPP_EXPORT Connection;
81 bool empty()
const {
return pool_.empty(); }
176 void clear(
bool all =
true);
210 size_t size()
const {
return pool_.size(); }
214 struct ConnectionInfo {
231 bool operator<(
const ConnectionInfo& rhs)
const
233 const ConnectionInfo& lhs = *
this;
234 return lhs.in_use == rhs.in_use ?
235 lhs.last_used < rhs.last_used :
239 typedef std::list<ConnectionInfo> PoolT;
240 typedef PoolT::iterator PoolIt;
243 Connection* find_mru();
244 void remove(
const PoolIt& it);
245 void remove_old_connections();
249 BeecryptMutex mutex_;
MUTually EXclusive lock class.
Manages a pool of connections for programs that need more than one Connection object at a time,...
Definition: cpool.h:69
virtual ~ConnectionPool()
Destroy object.
Definition: cpool.h:78
virtual void destroy(Connection *)=0
Destroy a connection.
size_t size() const
Returns the current size of the internal connection pool.
Definition: cpool.h:210
virtual unsigned int max_idle_time()=0
Returns the maximum number of seconds a connection is able to remain idle before it is dropped.
void shrink()
Remove all unused connections from the pool.
Definition: cpool.h:165
bool empty() const
Returns true if pool is empty.
Definition: cpool.h:81
ConnectionPool()
Create empty pool.
Definition: cpool.h:72
virtual Connection * create()=0
Create a new connection.
Manages the connection to the database server.
Definition: connection.h:60