Skip to content

ThreadSafeQueue is not thread safe for multiple readers #134

Open
@nahikia2

Description

Calling front() and pop() when the queue is empty is undefined behavior.
There are no operations provided that check empty() and then access the container while holding the mutex the entire time.

If there are two threads that look like this:

while(true) {
if (!queue.empty()) {
queue.pop();
}
}

It is likely that the queue is not empty when one thread checks the conditional statement, but it is empty when it tries to call pop().

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions