Refactors map test case
[libcds.git] / benchmark-drivers / fcdeque_driver.cpp
1 #include <cds/gc/dhp.h>
2 #include <cds/gc/hp.h>
3 #include <cds/init.h>
4 #include <cds/container/fcdeque.h>
5 #include <cds/intrusive/fcqueue.h>
6 #include <iostream>
7 #include <string>
8
9 using namespace std;
10
11 namespace ci = cds::intrusive;
12 namespace cc = cds::container;
13 typedef cds::gc::HP hp_gc;
14
15 struct Foo {
16   Foo(int x) : x(x) {}
17   int x;
18 };
19
20 // At least, declare the queue type
21 typedef cc::FCDeque<Foo> MyDeque;
22
23 int main() {
24   cds::Initialize();
25
26   {
27     // Initialize Hazard Pointer singleton
28     cds::gc::HP hpGC(128, 8, 128);
29     // If main thread uses lock-free containers
30     // the main thread should be attached to libcds infrastructure
31     cds::threading::Manager::attachThread();
32
33     MyDeque q;
34     Foo *f = new Foo(1);
35     Foo res(0);
36     q.push_front(*f);
37     bool succ = q.pop_front(res);
38     if (succ) {
39       cout << "Dequeued " << res.x << "\n";
40     } else {
41       cout << "Dequeued none\n";
42     }
43   }
44
45   cds::Terminate();
46   return 0;
47 }