Hi,
My application will continuously fill up the QWork object. Within certain interval it will fill up the QWork object. I want to reuse the threads you have created in pool in every interval it is filling up the QWork object.
I am giving you some code snippet:
&<code>
while (1)
{
sleep(10);
##execute the stored procedure##
##filling up the QWork object##
}
<code>&
How to do it?expecting your help. | [reply] |
Actually I want to send ithreads to wait-state when they complete their works.I want take those threads back from wait-state when their are data to get processed by threads.Can thr->signal can be used to put the threads to wait state? Please send me your advices.
| [reply] |
Is the AnonymousMonk above also you?
The threads will automatically go into a wait state when there is nothing in the queue. And as soon as you add something new to the queue, one of them will wake up to deal with it. That's the beauty of the architecture.
Now, assuming you're the AnonyMonk from above, the way to deal with the situation of the queue growing when you have large volumes of work items available very quickly, is to slightly restructure the code above to start the threads first, and then feed the work items into the queue in batches, and sleeping between batches to give the workers time to deal with them. There are several arrangements for doing this and the best choice will depend upon other details of your application.
If you confirm that you are the anonymonk and this is the problem you are encountering, and you are prepared to divulge a little further information about your application, then I'll try to suggest an applicable arrangement.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
Yep....I am anonymous monk.Sorry for replying late as I was busy with other works. Thanks for your siggestion. It has worked. I need to do one thing.....I need to create a pool of DBI connection. I tried to use Thread::Queue to create create thread-safe Queue for DBI connection. But it is throwing some error like something "Thread is unable to tie" those DBI connection variables. How to create DBI connection pool? I am planning to create an array of DBI connections & planning to use Thread::Semaphore. Will it be good idea? or any other readymade trick?
Waiting for your suggestion.
| [reply] |
| [reply] |