Opened 9 years ago

Last modified 9 years ago

#8666 new Feature Requests

boost::lockfree::spsc_queue::emplace_push

Reported by: aubrey@… Owned by: timblechmann
Milestone: To Be Determined Component: lockfree
Version: Boost 1.53.0 Severity: Optimization
Keywords: spsc_queue queue lockfree emplace Cc:

Description

It would be nice to be able to write the following function:

void producer_thread()
{
    while(isRunning)
    {
        T& item = q.emplace_write(); // This feature avoids the need to create the item
        write(item);
        q.emplace_push(); // This feature avoids the need to copy the item
    }
}

Implementing this: A slow consumer may be reading the item after the write index so the change is not as easy as exposing the next item. The change would require a gap of 1 item to always exist to avoid a read/write collision.

Jason Aubrey

Change History (2)

comment:1 by timblechmann, 9 years ago

to be honest, i'm not a big fan of this API. first, i don't know, if this is a real-world bottle-neck and if so, it should probably be wrapped into a Functor API for safety reasons.

comment:2 by anonymous, 9 years ago

Thanks for the feedback. I agree with the safety concern.

The idea came to me when I was looking to avoid creating another container for an object store. But it's not a big hassle to do so and then pass pointers through the queue.

Feel free to close the issue.

Note: See TracTickets for help on using tickets.