Opened 10 years ago

Closed 10 years ago

#7321 closed Bugs (fixed)

freelist_stack::allocate and freelist_stack::deallocate should not be private

Reported by: Hartmut Kaiser Owned by: timblechmann
Milestone: To Be Determined Component: lockfree
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

Currently, the allocate/deallocate functions et.al. in lockfree::detail::freelist_stack are private. This inhibits reusing this class for implementing other lock-free datastructures as it's not possible to allocate anything which has not a constructor taking 0, 1, or 2 arguments (those are supported explicitly by exposing overloads for freelist_stack::construct).

Would it be possible to make the mentioned functions 'protected' instead?

Change History (3)

comment:1 by timblechmann, 10 years ago

making allocate protected. deallocate should not be required, as one can still use the destruct method.

however in general it would be cleaner to use an api like this:

template <class... Args>
T * construct(Args&&... args)

in reply to:  1 comment:2 by Hartmut Kaiser, 10 years ago

Replying to timblechmann:

making allocate protected. deallocate should not be required, as one can still use the destruct method.

Hmmm. In another use case I'm using freelist_stack in a special memory pool. The deallocate function is necessary for me as I'm using it from inside of a placement delete operator (the compiler has already called the destructor for me, I only need to give the memory back to the freelist). Would it be possible to leave the deallocate function protected as well, please?

however in general it would be cleaner to use an api like this:

template <class... Args>
T * construct(Args&&... args)

I agree, except for the use case above, where placement new and delete are used.

comment:3 by timblechmann, 10 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.