X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=blobdiff_plain;f=output%2Fconcurrent-hashmap%2Fmain.cc;fp=output%2Fconcurrent-hashmap%2Fmain.cc;h=f39f3b6f6e64d48ee3edd9205698bf46c50028bb;hp=0000000000000000000000000000000000000000;hb=dddb190f43cd31d29dd0ce06739fc9cd22f25f73;hpb=03a40f095e6c8a1af2384093d164c15146c55f95 diff --git a/output/concurrent-hashmap/main.cc b/output/concurrent-hashmap/main.cc new file mode 100644 index 0000000..f39f3b6 --- /dev/null +++ b/output/concurrent-hashmap/main.cc @@ -0,0 +1,35 @@ +#include +#include +#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; +} + + +