active queue

Hi All,

First of all thanks for giving me the opportunity to join this forum.I am having one problem using the queue. Here is my problem definition ...
" I wanted to insert one message in a queue and once that message. Another thread is waiting for inserting in that queue. So, once something is inserted other process whats to read that else he will wait till the first thread enters something in the queue."

Is there any predefined queue in C++ for this type of problem ? If not how to do that . I can do it using while(1), but it takes lots of memory If I use while(1) .
Can anybody help me here ? ?
Hi,
You can use pthread conditional variables if u r using POSIX threads,
Producer thread will put the message and signal using the same condition variable on which the consumer is supposed to wait.
Consumer will read the queue for messages, if queue is empty then its wait on the condition till producer signals it.

Hope this will give you necessary info.
There is no predefined thread-safe message queue in the C++ standard library. One can create a thread-safe message queue fairly easily using the primitives available in the Boost Thread library.
Topic archived. No new replies allowed.