C++ implementation of production and consumer models