¿Es esta una forma correcta de implementar un búfer acotado en C ++ [cerrado]

Estoy trabajando en un programa que se ocupa de varios subprocesos que acceden, depositan y retiran de un contenedor de búfer acotado. He notado algunos problemas importantes con los subprocesos y sospecho que mi búfer es parcial o fundamentalmente incorrecto en algún lugar.

Para asegurarme de que sé lo que estoy haciendo con esto, agradecería que se revise mi código de búfer. La clase usa un Semáforo que implementé en otro lugar, que asumiré que funciona por ahora (¡si no, lo resolveré pronto!) He agregado comentarios que intentan explicar mi razonamiento.

Primero, el archivo .h:

#ifndef BOUNDED_BUFFER_H
#define BOUNDED_BUFFER_H

#include "Semaphore.H"
#include <string> 
#include <vector>  

using namespace std; 

class Item{ //supposed to eventually be more extensible...seems silly with just a string for now

  public:
    Item(string _content){content = _content;} 
    string GetContent() {return content;}     

  private:  
};   

    class BoundedBuffer{

      public:
        BoundedBuffer(); 

        void Deposit(Item* _item); 
        Item* Retrieve();        
        int GetNumItems() {return count;} 
        vector<Item*> GetBuffer() {return buffer;} 
        void SetSize(int _size){
          capacity = _size;
          buffer.reserve(_size);  //or do I need to call "resize" 
        }  

      private:
        int capacity; 
        vector<Item*> buffer; //I originally wanted to use an array but had trouble with  
                              //initilization/sizing, etc. 
        int nextin; 
            int nextout; 
            int count; 

            Semaphore notfull;   //wait on this one before depositing an item
            Semaphore notempty;  //wait on this one before retrieving an item
        };

    #endif

A continuación, el .cpp:

#include "BoundedBuffer.H"
#include <iostream>

using namespace std; 

BoundedBuffer::BoundedBuffer(){

  notfull.SetValue(0); 
  notempty.SetValue(0); 
  nextin = 0; 
  nextout = 0; 
  count = 0; 
}

void BoundedBuffer::Deposit(Item* _item){
  if(count == capacity){ 
    notfull.P(); //Cannot deposit into full buffer; wait
  }

  buffer[nextin] = _item; 
  nextin = (nextin + 1) % capacity;  //wrap-around
  count += 1;
  notempty.V();  //Signal that retrieval is safe 
}

Item* BoundedBuffer::Retrieve(){
  if(count == 0){
    notempty.P(); //cannot take from empty buffer; wait 
  }

  Item* x = buffer[nextout]; 
  nextout = (nextout + 1) % capacity;
  buffer.pop_back();  //or a different erase methodology? 
  count -= 1; 
  notfull.V(); //Signal that deposit is safe 
  return x; 
}

Creo que los problemas podrían surgir de mi elección de un vector como el contenedor subyacente (o, más bien, un uso incorrecto de él), o tal vez la necesidad de más mecanismos de bloqueo para la seguridad (bloqueos de exclusión mutua, etc.). Cosas, ¿alguien puede ofrecer algún comentario?

Respuestas a la pregunta(2)

Su respuesta a la pregunta