ada08ecf846ffae27ab70896a46c598c5ae4d88b
[model-checker-benchmarks.git] / spsc-bugfix / spsc-queue.cc
1 #include <threads.h>
2
3 #include "queue.h"
4
5 spsc_queue<int> *q;
6
7         void thread(unsigned thread_index)
8         {
9                 for (int i = 0; i < 40; i++) {
10                 if (0 == thread_index)
11                 {
12                         q->enqueue(11);
13                 }
14                 else
15                 {
16                         int d = q->dequeue();
17                         RL_ASSERT(11 == d);
18                 }
19                 }
20         }
21
22 int user_main(int argc, char **argv)
23 {
24         thrd_t A, B;
25
26         q = new spsc_queue<int>();
27
28         thrd_create(&A, (thrd_start_t)&thread, (void *)0);
29         thrd_create(&B, (thrd_start_t)&thread, (void *)1);
30         thrd_join(A);
31         thrd_join(B);
32
33         delete q;
34
35         return 0;
36 }