Cross compile works
[libcds.git] / benchmark-drivers / fcqueue_driver.cpp
diff --git a/benchmark-drivers/fcqueue_driver.cpp b/benchmark-drivers/fcqueue_driver.cpp
new file mode 100644 (file)
index 0000000..0431a12
--- /dev/null
@@ -0,0 +1,46 @@
+#include <cds/gc/dhp.h>
+#include <cds/gc/hp.h>
+#include <cds/init.h>
+#include <cds/intrusive/fcqueue.h>
+#include <iostream>
+#include <list>
+#include <string>
+
+using namespace std;
+
+namespace ci = cds::intrusive;
+typedef cds::gc::HP hp_gc;
+
+struct Foo : boost::intrusive::list_base_hook<> {
+  Foo(int x) : x(x) {}
+  int x;
+};
+
+// At least, declare the queue type
+typedef ci::FCQueue<Foo> MyQueue;
+
+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();
+
+    MyQueue q;
+    Foo *f = new Foo(1);
+    Foo *res = nullptr;
+    q.enqueue(*f);
+    res = q.dequeue();
+    if (res) {
+      cout << "Dequeued " << res->x << "\n";
+    } else {
+      cout << "Dequeued none\n\n";
+    }
+  }
+
+  cds::Terminate();
+  return 0;
+}