edits
[cdsspec-compiler.git] / benchmark / concurrent-hashmap / testcase1.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, 11);
9         printf("Thrd A: Put %d -> %d\n", 1, 11);
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, 22);
16         printf("Thrd B: Put %d -> %d\n", 2, 22);
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         table->put(1, 1);
26         table->put(2, 2);
27
28         thrd_create(&t1, threadA, NULL);
29         thrd_create(&t2, threadB, NULL);
30         thrd_join(t1);
31         thrd_join(t2);
32         
33         return 0;
34 }
35
36