Cross compile works
[libcds.git] / benchmark-drivers / fcdeque_driver.cpp
diff --git a/benchmark-drivers/fcdeque_driver.cpp b/benchmark-drivers/fcdeque_driver.cpp
new file mode 100644 (file)
index 0000000..18e2ae8
--- /dev/null
@@ -0,0 +1,47 @@
+#include <cds/gc/dhp.h>
+#include <cds/gc/hp.h>
+#include <cds/init.h>
+#include <cds/container/fcdeque.h>
+#include <cds/intrusive/fcqueue.h>
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+namespace ci = cds::intrusive;
+namespace cc = cds::container;
+typedef cds::gc::HP hp_gc;
+
+struct Foo {
+  Foo(int x) : x(x) {}
+  int x;
+};
+
+// At least, declare the queue type
+typedef cc::FCDeque<Foo> MyDeque;
+
+int main() {
+  cds::Initialize();
+
+  {
+    // Initialize Hazard Pointer singleton
+    cds::gc::HP hpGC(128, 8, 128);
+    // If main thread uses lock-free containers
+    // the main thread should be attached to libcds infrastructure
+    cds::threading::Manager::attachThread();
+
+    MyDeque q;
+    Foo *f = new Foo(1);
+    Foo res(0);
+    q.push_front(*f);
+    bool succ = q.pop_front(res);
+    if (succ) {
+      cout << "Dequeued " << res.x << "\n";
+    } else {
+      cout << "Dequeued none\n";
+    }
+  }
+
+  cds::Terminate();
+  return 0;
+}