954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Communication between processes

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

xagutxu
Newbie Poster
14 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Banfa
Practically a Master Poster
600 posts since Mar 2010
Reputation Points: 486
Solved Threads: 92
 

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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

xagutxu
Newbie Poster
14 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: