Boost logo

Boost :

Subject: Re: [boost] [lockfree review] rfc: naming and interface
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-07-21 20:54:07


On Thu, Jul 21, 2011 at 2:46 AM, Tim Blechmann <tim_at_[hidden]> wrote:

> hi all,
>
> i am starting a new thread, because i want to start a new discussion on one
> aspect of boost.lockfree: the naming of the data structure and the
> interface
>

I hope to look through the documentation and provide some feedback before
the end of the review.

> naming:
> the current names of the data structures are fifo, stack and ringbuffer.
> during
> the pre-review some people suggested to use different names, lifo instead
> of
> stack or queue instead of fifo.
> in general i think it is a good idea to use a consistent naming (probably
> fifo
> should be renamed to queue), but how does the ringbuffer come in? it is a
> queue
> as well, but with different characteristics (spsc and wait-free).
>

Queue, stack, and ring seem fine.

data structure configuration:
> stack and fifo currently use 3 template arguments: T for the managed type,
> freelist_t as a tag to select the underlying freelist and Alloc as the
> allocator
> which is used for the internal nodes:
>
> template<typename T,
> typename freelist_t = caching_freelist_t,
> typename Alloc = std::allocator<T> >
> class fifo/stack;
>
> however i have been thinking about replacing it with a boost.parameter
> interface, something like:
>
> template<typename T, ... Options>
> class fifo/stack;
>
> with the options:
>
> boost::lockfree::freelist_can_allocate<true/false> to disable memory
> allocation during enqueue/push
>
> boost::lockfree::allocator<> to specify the allocator
>

Boost.Parameter seems like overkill for just 2 optional parameters.

If you have plans for expanding the class of policies one can specify in the
future, however...

ringbuffer size:
> the ringbuffer currently has the signature:
>
> template<typename T, size_t max_size> class ringbuffer;
>
> if max_size is 0, the size of the ringbuffer can be configured at run-time
> with
> a constructor. this is not really the cleanest interface, but i would like
> to
> provide an interface, which supports both compile-time and run-time setting
> of
> the size.
>

Actually, I think it's reasonably clean, if max_size defaults to 0, so that
a dynamic max_size ring is simply ring<T>.

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk