Skip to content

maxSize parameter is not obeyed #73

@KungFuJesus

Description

@KungFuJesus

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions