Salve,

sono un pò ingarbugliato nel codice che segue...ogni spiegazione è inserita nei commenti del codice:

Codice PHP:
#include <windows.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <boost/circular_buffer.hpp>
using namespace std;
using namespace boost;

void getDateTime(char szTime);
const 
int numbuff 3;
const 
int buflen  30;

struct buffer
{
    
unsigned char data[1024];
    
int bytesRecorded;
    
int user;
    
buffer(const unsigned char data_, const int bytesRecorded_, const int user_) :
        
bytesRecorded(bytesRecorded_), user(user_)
        {
            
copy(data_data_ bytesRecorded_data);
        }
};

struct circular
{
    
circular_buffer<buffercb[numbuff];
};

int main()
{
    
/*
     * Vorrei mettere in un array associativo
     * un /int/ e una struttura /circular/ che
     * a sua volta contiene un buffer circolare
     * di "numbuff" elementi (buffers) ogni volta
     * che faccio push_back aggiungo un nuovo
     * elemento verso la pila (sovrascrivo il più
     * vecchio).
     */

    
map<intcircularusers// globale!

    /*
     * In questa parte il "Consumer"
     * aggiunge un nuovo elemento alla mappa
     * (nuovo buffer circolare sul quale
     * il "Producer" scriverà)
     */

    
int regkey 1;                     // Chiave nella mappa
    
circular c;                         // buffer vuoto
    
users.insert(make_pair(regkeyc)); // aggiunto alla mappa

    /*
     * Quando il "Consumer" vuole uscire dalla
     * mappa non dovrà fare altro che rimuoversi
     * tramite la propria regkey
     */

    
users.erase(regkey);

    
/*
     * Ora viene il difficile! Il "Producer"
     * deve scrivere tutti i buffer degli
     * elementi che sono presenti nella mappa.
     * Sempre seguendo la logica del buffer
     * circolare. Quindi il metodo è push back.
     */

    
map<intcircular>::const_iterator it;

    
// while(1) ...thread...
    // scriviamo qualcosa di diverso ogni volta nei buffers
    
char szTime[30]; getDateTime(szTime);

    for(
it=users.begin(); it!=users.end(); ++it)
    {
        
//
        // Facendo push_back so che sto scrivendo
        // oppure sovrascrivendo sull'ultimo elemento
        // nella pila dei buffers
        //
        
it->second.cb->push_back(buffer((unsigned char*)szTime301));

        
// purtroppo ottengo questo errore:
        // error C2662: 'boost::circular_buffer<T>::push_back' : 
        // cannot convert 'this' pointer
        // from 'const boost::circular_buffer<T>' to 'boost::circular_buffer<T> &'
    
}

    
system("pause");
    return 
EXIT_SUCCESS;
}

void getDateTime(char szTime)
{
    
time_t rawtime time(NULL);
    
struct tm timeinfo;
    
gmtime_s(&timeinfo, &rawtime);
    
strftime(szTime30"%a, %d %b %Y %X GMT", &timeinfo);

In pratica ho una mappa che contiene come chiave un numero int e come valore una struttura circular che a sua volta contiene una struttura buffer

La chiave mi servirà per aggiungere e/o rimuovere la struttura circular dalla mappa. Questo è solo uno schema generale di come dovrò affrontare la questione "Producer" e "Consumer" dove il "Producer" scriverà su tutti i buffers (circolari) contenuti nella mappa ed il "Consumer" a sua volta legge questi dati (ovvero legge l'ultimo elemento del buffer circolare)

Devo dire cmq che sono moolto in altomare...

grazie