aboutsummaryrefslogtreecommitdiffstats
path: root/tests/syncqueuetest.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-22 21:16:02 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-22 21:19:21 +0000
commitfb8197839c0bebc20fd68ee3f280da934c49c473 (patch)
treee4ccb024144cb5b41f9e572984e3278c2b0b51d0 /tests/syncqueuetest.cpp
parentd6b25272499352383214c738faa8ce1870df37f3 (diff)
downloadYAGE-fb8197839c0bebc20fd68ee3f280da934c49c473.tar.gz
YAGE-fb8197839c0bebc20fd68ee3f280da934c49c473.zip
Removing editor and refactoring code.
Diffstat (limited to 'tests/syncqueuetest.cpp')
-rw-r--r--tests/syncqueuetest.cpp53
1 files changed, 0 insertions, 53 deletions
diff --git a/tests/syncqueuetest.cpp b/tests/syncqueuetest.cpp
deleted file mode 100644
index 1d7d8037..00000000
--- a/tests/syncqueuetest.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: syncqueuetest.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include <yage.h>
-
-#include <atomic>
-#include <thread>
-
-using namespace yage;
-
-SyncQueue<int> queue;
-std::atomic_int j(0);
-
-void push_to_queue1(int elements)
-{
- for (int i = 0; i < elements; i++) {
- queue.push(1);
- j.fetch_add(1, std::memory_order_relaxed);
- }
- std::cout << "Done 1\n";
-}
-
-void push_to_queue2(int elements)
-{
- for (int i = 0; i < elements; i++) {
- queue.push(2);
- j.fetch_add(1, std::memory_order_relaxed);
- }
- std::cout << "Done 2\n";
-}
-
-int main()
-{
- std::thread first(push_to_queue1, 100000);
- std::thread second(push_to_queue2, 100000);
-
- std::cout << "created threads, now adding in main\n";
- for (int i = 0; i < 1000000; ++i) {
- queue.push(i);
- j.fetch_add(1, std::memory_order_relaxed);
- }
-
- std::cout << "now joining the threads\n";
- first.join();
- second.join();
- std::cout << "done\n"
- << "iterations: " << j << "\n";
-}