X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=spsc-bugfix%2Fspsc-queue.cc;fp=spsc-bugfix%2Fspsc-queue.cc;h=f8528a862acd8f5097ebb3d781e73e8eb7955864;hb=991d0fdc0fb17f85d485c97dc2c5d8d57a98dad9;hp=0000000000000000000000000000000000000000;hpb=91db0c118d7135f69846bcedfb8a26c0afb44045;p=model-checker-benchmarks.git diff --git a/spsc-bugfix/spsc-queue.cc b/spsc-bugfix/spsc-queue.cc new file mode 100644 index 0000000..f8528a8 --- /dev/null +++ b/spsc-bugfix/spsc-queue.cc @@ -0,0 +1,34 @@ +#include + +#include "queue.h" + +spsc_queue *q; + + void thread(unsigned thread_index) + { + if (0 == thread_index) + { + q->enqueue(11); + } + else + { + int d = q->dequeue(); + RL_ASSERT(11 == d); + } + } + +int user_main(int argc, char **argv) +{ + thrd_t A, B; + + q = new spsc_queue(); + + thrd_create(&A, (thrd_start_t)&thread, (void *)0); + thrd_create(&B, (thrd_start_t)&thread, (void *)1); + thrd_join(A); + thrd_join(B); + + delete q; + + return 0; +}