|
|||||||||||
|
RE: Stay connected with DB
From: <reid.madsen(at)exgate.tek.com>
Date: Tue Jun 05 2007 - 14:50:13 EDT
In regards to #1, this snippet was from such a class as you described -- the getPoolConnection just managed the list of connections. (A minor nit). I agree all or in part to all other points. I'll consider formalizing this into a class that could be included in MySQL++. Reid
-----Original Message-----
reid.madsen@exgate.tek.com wrote:
No, sorry, I don't like it. I would make several changes:
class ConnectionPool {
public:
ConnectionPool() { }
Connection* connection();
protected:
// subclass overrides
virtual Connection* create() = 0;
virtual unsigned int max_lifetime() = 0;
private:
struct ConnectionInfo {
Connection* conn;
time_t last_used;
bool in_use;
ConnectionInfo(Connection* c) :
conn(c), last_used(time(0)), in_use(true) { }
};
std::listIf you'd be willing to implement this interface and release the code, I think this might be useful to add to MySQL++. This possibility is why I designed it with create() and max_lifetime() being template methods, since MySQL++ cannot know how to properly create the connection or what the timeout should be. A subclass could also turn this into a singleton, another thing that is outside MySQL++'s scope, since correct singleton destruction depends on the program's design. -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=reid.madsen@tek.com -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=lists@pantek.comReceived on Tue Jun 5 14:51:17 2007 This archive was generated by hypermail 2.1.8 : Tue Jun 05 2007 - 15:00:02 EDT |
||||||||||
|
|||||||||||