edits
[cdsspec-compiler.git] / output / concurrent-hashmap / main.cc
diff --git a/output/concurrent-hashmap/main.cc b/output/concurrent-hashmap/main.cc
new file mode 100644 (file)
index 0000000..f39f3b6
--- /dev/null
@@ -0,0 +1,35 @@
+#include <iostream>
+#include <threads.h>
+#include "hashmap.h"
+
+HashMap *table;
+
+void threadA(void *arg) {
+       table->put(1, 1);
+       printf("Thrd A: Put %d -> %d\n", 1, 1);
+       int r1 = table->get(2);
+       printf("Thrd A: Get %d\n", r1);
+}
+
+void threadB(void *arg) {
+       table->put(2, 2);
+       printf("Thrd B: Put %d -> %d\n", 2, 2);
+       int r2 = table->get(1);
+       printf("Thrd B: Get %d\n", r2);
+}
+
+int user_main(int argc, char *argv[]) {
+       thrd_t t1, t2;
+
+       table = new HashMap;
+
+       thrd_create(&t1, threadA, NULL);
+       thrd_create(&t2, threadB, NULL);
+       thrd_join(t1);
+       thrd_join(t2);
+       
+       return 0;
+}
+
+
+