Hello:

I am trying to create an audio processor, and I have a program that creates some threads (in Windows). The "main" program creates the audio processor thread, and then creates the audio reader thread. I would like to know how the audio reader can tell the processor that the audio has finished. I have tried with events, but (correct me if I am wrong) when using events a thread has to wait until the other sets the event; and it is not may case, because in my processor thread the processor is working inside a loop that has to check if the audio-picking has finished; if not, it continues working.

Any help...?

Thank you,

Xagutxu

Recommended Answers

All 4 Replies

You do not have to wait to see if an event is set. You can test the event without waiting if you call something like WaitForSingleObject with the dwMilliseconds parameter set to 0 then the function will return immediately indicating if the event signalled or not at that time.

If these are threads within the same process as opposed to threads in different processes, you can use a thread-safe data structure to share these signals. In my opinion that's easier than implementing an inter-process communication mechanism just for threads.

Thank you for answering so quickly...

Could you tell me wether there is any structure or method in C++ to manage with those thread-safe data structure?

Thank you again,

Xagutxu

Google (or search stackoverflow.com) for thread-safe queues. You should get plenty of food for thought.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.