5 #include "mpmc-queue.h"
9 void threadA(struct mpmc_boundq_1_alt<int32_t> *queue)
11 int32_t *bin = write_prepare(queue);
13 //printf("Thread A: bin=%d", bin);
15 write_publish(queue, bin);
19 void threadB(struct mpmc_boundq_1_alt<int32_t> *queue)
22 if ((bin = read_fetch(queue)) != NULL) {
23 //printf("Read: %d\n", load_32(bin));
24 read_consume(queue, bin);
28 void threadC(struct mpmc_boundq_1_alt<int32_t> *queue)
30 int32_t *bin = write_prepare(queue);
33 write_publish(queue, bin);
36 while ((bin = read_fetch(queue)) != NULL) {
37 //printf("Read: %d\n", load_32(bin));
38 read_consume(queue, bin);
43 int user_main(int argc, char **argv)
45 mpmc_boundq_1_alt<int32_t> *queue = createMPMC(2);
49 // A queue of capacity 2, 2 writes happened very early
50 int32_t *bin = write_prepare(queue);
51 write_publish(queue, bin);
52 bin = write_prepare(queue);
53 write_publish(queue, bin);
55 printf("Start threads\n");
57 thrd_create(&A, (thrd_start_t)&threadA, queue);
58 thrd_create(&B, (thrd_start_t)&threadB, queue);
59 //thrd_create(&C, (thrd_start_t)&threadC, queue);
65 printf("Threads complete\n");