Skip to content

Can boost::lockfree::queue's pop return false for non-empty queue? #119

@ara-ayvazyan

Description

@ara-ayvazyan

Documentation states, that pop returns

true, if the pop operation is successful, false if queue was empty.

However, the following example asserts sometimes (MSVC 19.42, even in debug) during pop:

boost::lockfree::queue<int> queue{0u};
const auto work = [&]
{
    while (true)
    {
        int x = 0;
        BOOST_VERIFY(queue.push(x));
        BOOST_VERIFY(queue.pop(x));
    }
};
std::jthread t0{ work };
std::jthread t1{ work };

The issue doesn't seem to happen when there is a barrier between the push and pop calls, suggesting that parallel push and pop calls may result in pop returning false, even when the initial queue isn't empty.

Metadata

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