Boost logo

Boost Users :

Subject: Re: [Boost-users] lockfree : getting a move only type into spsc_queue
From: Thomas Novotny (tnovotny_at_[hidden])
Date: 2016-07-24 10:08:06


On 24.07.2016 13:04, Bjorn Reese wrote:
> On 07/23/2016 11:36 PM, Thomas Novotny wrote:
>
>> In the end Imade a custom version of spsc_queue. Getting this working
>> (as a hack) was fairly easy, so I wanted to share it in the hope that a
>> better solution might make it into a future version of the library.
>
> FYI, there is a pull request about adding move support to spsc_queue,
> but the consequences have not been fully examined yet:
>
> https://github.com/boostorg/lockfree/pull/24

That is good news, but unfortunately this doesn't work for me because it
does not support moving out. I still get a compile error for the pop
(attempting to reference a deleted function)

     size_t pop (T * output_buffer, size_t output_count, T *
internal_buffer, size_t max_size)
        ...
       copy_and_delete(...)

because it copies.

> In the meanwhile, you can make a cleaner solution with a unique_ptr
> specialization of spsc_queue. See attachment.
>
>> bool push( T & t, T * buffer, size_t max_size )
>
> T&& t
>

While your solution is undoubtedly much cleaner, it also does not work
for me because my move only type does not expose the underlying
unique_ptr. In particular it does not have a release or any comparable
mechanism because of the custom deleter. Still, its an interesting
option to have.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net