Skip to content

Instantly share code, notes, and snippets.

@prasadwrites
Created October 22, 2019 20:37
Show Gist options
  • Save prasadwrites/93610c7696eb2ecf7282193188053182 to your computer and use it in GitHub Desktop.
Save prasadwrites/93610c7696eb2ecf7282193188053182 to your computer and use it in GitHub Desktop.
TBB concurrent queue example
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_priority_queue.h>
#include <iostream>
int array[10] = { 0,11,22,33,44,55,66,77,88,99 };
void test_queue() {
//creation of concurrent queue
tbb::concurrent_queue <int> queue;
int val;
//pushing the array items into the queue one by one
for (int i = 0; i < 10; ++i)
queue.push(array[i]);
std::cout << "poped values are " << std::endl;
//trying to pop out the values one bye one
for (int i = 0; i < 10; i++) {
queue.try_pop(val);
std::cout << val << std::endl;
}
std::cout << std::endl;
}
int main()
{
test_queue();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment