Parallel Comparison of C++ and Ada Producer-Consumer Implementations
Producer Consumer Comparison The C++ source code for this example is taken from the blog post here by Andrew Wei. A detailed description of the C++ software is given in the blog post. This solution is shown in parallel with a corresponding Ada solution. Both C++ and Ada separate interface specifications from implementation. C++ uses the header file, in this case the file named Buffer.hpp, to provide the interface specification for the buffer used in this example. C++ is not very strict about what goes into a header file and what goes into a .cpp file. The Ada version creates an Ada package. The Ada package specification defines the task types named producer_Int and consumer_Int. The buffer shared by all instances of producer_int and consumer_int is defined within the Ada package body file. Interface Specification Files Ada C++ package pc_tasks is task type produce_Int (Id : Natural); task type consume_Int (Id : Natura...