Here's the scenario as best I can explain it briefly:
I have one boss thread that recieves and distributes jobs to a set number of continuously running Worker threads. I don't think I have the option to start new threads when a new job is created, nor can I have the threads close when they are done processing their current job.
I had intended to communicate between them using a queue for the thread. The Boss thread would get jobs for the workers and place them in various worker thread's queues. These jobs the Workers have to perform have varying lengths of time needed for processing so there's no guarentees on when one will be completed and the next started.
The problem I have is how to block the Workers when their queue is empty. I don't want them constantly polling the queue looking for work, that would needlessly bog down the CPU. And I can't have them lock a mutex or semaphore when the queue is empty since that lock will be assigned to the Worker not the Boss so the Boss thread won't be able to add to the queue.
Is there a way to block the thread (without using the Sleep() function) until something is placed in the queue? Or is the method I'm trying to implement just never going to work?
Thanks in advance for any help or suggestions.