I have a decoder that acts as a producer and places decoded video frames at a shared memory buffer. I have consumer processes that each runs on a separate thread, reads a frame and processes it. I would like to implement a dispatcher process thread that
- Checks the shared memory buffer and sends teh next unread frame to a selected consumer thread from the pool
- If the shared buffer starts to get full (say, more than 90%), spawns more consumer threads
I'm thinking of writing this in C++ using boost interprocess and thread.
Any pointers you can suggest on how I can proceed? What strategy should the dispatcher follow to spawn more threads, since (AFAIK) this is expensive? Is the boost circular_buffer container a good choice for the buffer?
Thanks a lot,
C