Hello, I'm trying to set a maximum depth with the BlockingReaderWriterQueue so that I can basically spinlock until a thread frees room. However, it seems to allow me to add +1 more than the maximum size (and my max size needs to be 2). A simple example:
#include <readerwriterqueue/readerwriterqueue.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
moodycamel::BlockingReaderWriterQueue<int> q(2);
while(!q.try_enqueue(8));
usleep(50000);
printf("enqueued 8\n");
while(!q.try_enqueue(9));
usleep(50000);
printf("enqueued 9\n");
while(!q.try_enqueue(10));
usleep(50000);
printf("enqueued 10\n");
while(!q.try_enqueue(10));
usleep(50000);
printf("enqueued 10\n");
return 0;
}
Hello, I'm trying to set a maximum depth with the BlockingReaderWriterQueue so that I can basically spinlock until a thread frees room. However, it seems to allow me to add +1 more than the maximum size (and my max size needs to be 2). A simple example: