liveBook · Manning

Producer

As explained in Object-Oriented Software Design in C++

A producer is a concurrent software component or thread that creates and enters values into a shared data structure.

A producer is a concurrent component or thread that creates values and enters them into a shared queue. In a producer–consumer design, it coordinates with consumers through a bounded queue, mutex, and condition variables. section 16.3.2

Two producers and three consumers

A shared queue with capacity eight receives five values from each of two producer threads. Three consumers remove values concurrently; output shows insertion and removal order as scheduling varies.

Producer #1   Producer #2   Consumer #1   Consumer #2   Consumer #3   
   1 (1)   
                              -1 (0)   
                 2 (1)   
                              -2 (0)   
   3 (1)   
                                            -3 (0)   
                 4 (1)   
                                                          -4 (0)   
   5 (1)   
                                                          -5 (0)   
                 6 (1)   
                 7 (2)   
                              -6 (1)   
                 8 (2)   
                 Done!
                                                          -7 (1)   
                              -8 (0)   
   9 (1)   
  10 (2)   
   Done!
                                            -9 (1)   
                                                         -10 (0)   
                                             Done!
                                                           Done!
                               Done!

Browse an interleaved run showing producers filling the queue and consumers removing values. section 16.3.2

How Object-Oriented Software Design in C++ covers it

How deep it goes
Explains configuration, thread startup, waiting, queue insertion, and completion tracking, while deferring full method bodies.
Examples
Demonstrates two producers inserting five values each into an eight-item queue alongside three consumers.
What it assumes
Assumes C++ class and thread constructs while demonstrating synchronization through queues, mutexes, condition variables, and atomics.
What you can do after
Build a C++ producer that starts worker threads, respects queue capacity, and signals coordinated completion.
How it connects
Connects producers with consumers, shared queues, mutexes, condition variables, threads, and atomic variables.

Also explained in

Compare how 8 books explain producer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Object-Oriented Software Design in C++. The section links point to the parts of the book it draws on.