TerraLib 4.1
TeConnectionPool Class Reference

#include <TeConnectionPool.h>

List of all members.

Public Member Functions

bool initialize (const std::string &user, const std::string &password, const std::string &host, const std::string &dbName, const std::string &dbmsName, const int &portNumber)
 Intializes the pool of connections given a set of parameters.
TeConnectiongetConnection ()
 Gets a free connection that can be used for a TeDatabase instance.
void releaseConnection (TeConnection *conn)
 Releases the given connection.
Constructor

Initilizer methods.

 TeConnectionPool (const unsigned int &maxConnections, const unsigned int &maxIdle=0, const clock_t &maxWait=10000)
 Constructor.
 ~TeConnectionPool ()
 Destructor.
Access method.

Method to access the pool attrbiutes.

void setTimeOut (const clock_t t)
 Sets the time limit to wait for a connection (in milliseconds).

Constructor & Destructor Documentation

TeConnectionPool::TeConnectionPool ( const unsigned int &  maxConnections,
const unsigned int &  maxIdle = 0,
const clock_t &  maxWait = 10000 
)

Constructor.

Parameters:
nConnsThe number of connections that will be controlled by the pool.
timeOutTime limit to wait for a connection (in milliseconds).
TeConnectionPool::~TeConnectionPool ( )

Destructor.


Member Function Documentation

TeConnection * TeConnectionPool::getConnection ( )

Gets a free connection that can be used for a TeDatabase instance.

Note:
This method is thread-safe.
The caller of this method will NOT take the ownership of the returned pointer.
Case not exists a free connection, the caller will wait on a queue for one, respecting the time out.
Case time out exceeds a NULL pointer will be returned.
The connection should be repassed again to the pool after used using the method releaseConnection. Example: { TeConnection* c = pool->getConnection(); db->setConnection(c); // TeDatabase instance do something... pool->releaseConnection(c); }
bool TeConnectionPool::initialize ( const std::string user,
const std::string password,
const std::string host,
const std::string dbName,
const std::string dbmsName,
const int &  portNumber 
)

Intializes the pool of connections given a set of parameters.

Parameters:
userThe database user.
passwordThe user password.
hostThe database host.
dbNameThe database name.
dbmsNameThe database manager system name (i.e. PostgreSQL, Access).
portNumberThe database port.
void TeConnectionPool::releaseConnection ( TeConnection conn)

Releases the given connection.

Note:
This method is thread-safe.
The given connection will be deleted.
void TeConnectionPool::setTimeOut ( const clock_t  t)

Sets the time limit to wait for a connection (in milliseconds).


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines