Home Projects Jobs Clientele Contact


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Db pool [was: My little comments to CPP code]

>> I meant for ThreadPool to be only an example on how CWaiters can be
>> used,
>> not as reference in implementation of database pool design. They are
>> different
>> in many ways (one of them - threads actually do something themselves,
>> while
>> database connections only have operations performed on them by those who
>> request them.)
>> Again - a pencil and a piece of paper, with little drawing of who does
>> what
>> might help you. The line in a super-market analogy can work fairly well,
>> if you map
>> your objects properly.
> So here is the case when getConnection() is called, but maxCon limit has
> been reached.
> 1. Check if there is an available connection in the pool, if yes, return
> it.
> 2. If no available connection, then wait 'timeout' milliseconds.
> 3. If connection is released, CWaiter sends a signal from
> releaseConnection() to notify getConnection() that there is an available
> connection.
> 4. If 'timeout' is over, return null. Otherwise call getConnection()
> again.

To be more precise:
4. If timeout is over _before_ signal recieved, return null. Otherwise
call getConnection() again.

>> --
>> Ilya A. Volynets-Evenbakh
>> Total Knowledge. CTO
>> http://www.total-knowledge.com

Authoright © Total Knowledge: 2001-2008