Hi
I have come up with a Singleton class that manages a pool of database connections. Basically the pool is a queue in which I have stored some connection objects. When ever a client calls any of the database class methods a connection object is popped from the queue and when done the connection is pushed on the queue. If the there are no more connections then that thread has to wait for signal when the pool has a connection then a signal is broadcasted to the wait thread. And now some code
Code: if(dbPool.size() != 0)
{
pthread_mutex_lock(&criticalSection);
DNativeDb activeDbObj = dbPool.pop();
pthread_mutex_lock(&criticalSection);
...
}First Question: Is it ok to put pop() under the a mutex_lock
elsewhere in code
Code: pthread_mutex_lock(&criticalSection);
dbPool.push(activeObj);
if(dbPool.size() == 1)
{
pthread_cond_broadcast(&cond);
}
thread_mutex_lock(&criticalSection);Second: When my pool has 1 connection object left then I need to broadcast incase some thread that might be waiting can then acquire the object. Is this the right way to achieve pool based connecting handling. Please guide and suggest if I am going wrong anywhere.
Thanks
Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to put the CRON code do I put it in the header between the head tags? do I put it before any html code?
help with image upload code
Hello,right now this code I have resizes images and then places them into the uploads folder is there a way to make this code upload the orignal file sizes into uploads and make it put the smaller
PHP and Javascript
Hello Everyone,I have a page that needs a javascript code to be written between PHP code but the condition is that javascript code should not be executed. How can I prevent javascript code to be
DBCA Templates
Hi all,I'm working on creating a template for DBCA, but can't find any documentation on the parameters that one can use within the template. Obviously most are fairly obvious, but I'd like to see
Edit MySQL Row Using PHP and HTML Form
Hello,Here's what I'm trying to do. Build a page where a user enters a MySQL row number in. Then, a new page appears with an HTML form where the user can edit the information in that row. Like for
Creating Images from images in PHP
Okay well I am trying to make a 'dynamic' calender image with PHP.I have images like this:and:Obv I have an image for each day of the month (1 - 31) and I have images for each month.if i created a
check_changed_data - I can't get data from the called method event
I use check_changed_data to trigger my event method.
Email Processor
I have a few questions so this post will be a larger one! Sorry, but I'm a bit of a PHP newbie so be gentle with me! Awhile back I wrote out a simple forum to email processor that I used with a few
PHP Programming error. Please help!
Hi there,Am making a website for a friend and have encountered a problem that i need fixing fast.I get this error when i try to run the code below: QuotePHP Error MessageWarning: Unexpected character
PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending upon where the visitor comes from. The code below works but looses the original referrer information