#include "test.h"
|
using namespace std;
|
|
int main () {
|
unsigned int i = 0;
|
|
|
|
struct Item item;
|
|
size_t qsize = 1;
|
LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (2, qsize);
|
|
// LockFreeQueue<struct Item> queue(16);
|
for(i = 0; i < qsize; i++) {
|
|
if(queue->push({i, i})) {
|
cout << i << " push:" << i << endl;
|
}
|
}
|
|
// for(i = 0; i < qsize; i++) {
|
|
// //queue.dequeue(item);
|
|
// item = (*queue)[i];
|
// cout << "i=" << i << " item " << item.pic << "," << item.info << endl;
|
// }
|
|
|
|
struct timespec timeout = {5, 0};
|
|
i = 0;
|
while((queue->pop(item)) ) {
|
cout << i << " 出队:" << item.pic << ", " << item.info << endl;
|
// cout << item.pic << endl;
|
|
i++;
|
|
}
|
|
|
destroy();
|
|
}
|