fixed commutativity rule
[cdsspec-compiler.git] / benchmark / concurrent-hashmap / main.cc
1 #include <iostream>
2 #include <threads.h>
3 #include "hashmap.h"
4
5 HashMap *table;
6
7 void threadA(void *arg) {
8         table->put(1, 1);
9         printf("Thrd A: Put %d -> %d\n", 1, 1);
10         int r1 = table->get(2);
11         printf("Thrd A: Get %d\n", r1);
12 }
13
14 void threadB(void *arg) {
15         table->put(2, 2);
16         printf("Thrd B: Put %d -> %d\n", 2, 2);
17         int r2 = table->get(1);
18         printf("Thrd B: Get %d\n", r2);
19 }
20
21 int user_main(int argc, char *argv[]) {
22         thrd_t t1, t2;
23
24         table = new HashMap;
25
26         thrd_create(&t1, threadA, NULL);
27         thrd_create(&t2, threadB, NULL);
28         thrd_join(t1);
29         thrd_join(t2);
30         
31         return 0;
32 }
33
34