changeset 974:c18acbe4f4da

add rbtreeTest with SynchronizedQueue
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Tue, 07 Sep 2021 19:59:49 +0900
parents 864a52dfef0a
children 18650c9ff2b2
files src/parallel_execution/CMakeLists.txt src/parallel_execution/RedBlackTree.cbc src/parallel_execution/examples/rbtTest_sync/rbTree_sync_test.cbc
diffstat 3 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Mon Jul 19 19:48:45 2021 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Sep 07 19:59:49 2021 +0900
@@ -180,3 +180,10 @@
   TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc examples/helloWorld/main.cbc examples/helloWorld/HelloImpl.cbc
 )
 
+
+GearsCommand(
+  TARGET
+      rbtree_sync
+  SOURCES
+      SingleLinkedQueue.cbc SynchronizedQueue.cbc AtomicReference.cbc examples/rbtTest_sync/rbTree_sync_test.cbc RedBlackTree.cbc SingleLinkedStack.cbc compare.c
+)
--- a/src/parallel_execution/RedBlackTree.cbc	Mon Jul 19 19:48:45 2021 +0900
+++ b/src/parallel_execution/RedBlackTree.cbc	Tue Sep 07 19:59:49 2021 +0900
@@ -40,7 +40,7 @@
 __code putRedBlackTree(struct RedBlackTree* tree, struct Node* node) {
     struct Node* newNode = &ALLOCATE(context, Node)->Node;
     struct Node* root = tree->root;
-    printTree((union Data*)(tree->root));
+    //printTree((union Data*)(tree->root));
     tree->newNode = newNode;
     tree->root = newNode; // this should done at stackClear
     tree->parent = NULL;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/examples/rbtTest_sync/rbTree_sync_test.cbc	Tue Sep 07 19:59:49 2021 +0900
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include "../../../context.h"
+#interface "Tree.h"
+#interface "Queue.h"
+
+/* #include <assert.h> */
+
+__code rbTreeTest1(struct Tree* tree) {
+  printf("Test1\n");
+  tree = createRedBlackTree(context);
+  Node* node = new Node();
+
+  node->value = (union Data*) createSynchronizedQueue(context);
+  node->key = 3;
+  
+  goto tree->put(node, rbTreeTest2);
+}
+
+__code rbTreeTest2(struct Tree* tree) {
+  printf("Test2\n");
+  Node* node = new Node();
+  node->value = (union Data*) createSynchronizedQueue(context);
+  node->key = 4;
+  goto tree->put(node, exit_code);
+}
+
+
+int main(int argc, char const* argv[]) {
+  printf("test_main\n");
+  goto rbTreeTest1();
+}