#include int main(int argc, char* argv[]) { using namespace boost::lockfree; size_t capacity=8; spsc_queue q(capacity); unsigned char data[]={45, 14, 7, 34, 2}; // 5 elements unsigned char* dst=new unsigned char[sizeof(data)]; // push array {45, 14, 7, 34, 2} q.push(data, sizeof(data)); // read data into dst buffer // using size_t pop(OutputIterator it) // the returned count is 5 size_t count=q.pop(dst); // check that data and dst are identical // rc is 0 int rc=memcmp(data, dst, sizeof(data)); // push array {45, 14, 7, 34, 2} // after that operation the stored data // consists of 2 fragments q.push(data, sizeof(data)); // read data into dst buffer // using size_t pop(OutputIterator it) // the returned count is 5 //* ERROR: //* If the stored data consists of 2 fragments //* the pop(OutputIterator it) will not work properly //* for random-access-iterator //* the second fragmet will be written starting from //* the same point as the first fragment: //* See spsc_queue.hpp:224 //* //* std::copy(internal_buffer + read_index, internal_buffer + max_size, it); //* std::copy(internal_buffer, internal_buffer + count1, it); //* //* The code should be: //* it=std::copy(internal_buffer + read_index, internal_buffer + max_size, it); //* std::copy(internal_buffer, internal_buffer + count1, it); count=q.pop(dst); //* ERROR //* check that data and dst are NOT identical //* rc is 1 rc=memcmp(data, dst, sizeof(data)); delete[] dst; return 0; }