#include <iostream>
#include <tbb/concurrent_queue.h>

#define N 5

using namespace std;
using namespace tbb;

typedef concurrent_bounded_queue<int> CQ;

int main()
{
	CQ cq;
	CQ::iterator it_cq;

	for ( int i=0; i<N; i++ ) {
		cq.push(2+i);
	}

	cout << "Printing the values in CQ" << endl;
	for ( it_cq = cq.unsafe_begin(); it_cq != cq.unsafe_end(); it_cq++ ) {
		cout << "\t" << *it_cq << endl;
	}
	cout << endl;

	cout << "CQ.try_push(10)" << endl;
	cq.try_push(10);
	for ( it_cq = cq.unsafe_begin(); it_cq != cq.unsafe_end(); it_cq++ ) {
		cout << "\t" << *it_cq << endl;
	}
	cout << endl;

	cout << "CQ.size() gives " << cq.size() << endl << endl;

	int x;
	cq.try_pop( x );
	cout << "CQ.try_pop() gives " << x << endl << endl;

	cout << "Printing the values in CQ" << endl;
	for ( it_cq = cq.unsafe_begin(); it_cq != cq.unsafe_end(); it_cq++ ) {
		cout << "\t" << *it_cq << endl;
	}
	cout << endl;

	return 0;
}

