Boost logo

Boost :

Subject: Re: [boost] [lockfree review] rfc: naming and interface
From: Tim Blechmann (tim_at_[hidden])
Date: 2011-07-22 04:47:58


hi all,

i've modified the interface and uploaded a snapshot of the docs to
http://tim.klingt.org/boost_lockfree_wip (_wip for `work in progress', the
original documentation is still online)

> 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.

i have decided to use the names queue, stack and ringbuffer. i came to the
conclusion that `ringbuffer' is probably better than ring or circular_buffer,
because there are many implementations of the same algorithm that use this name.

> 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:

both stack and queue now support boost.parameter template arguments:

queue<T, ...Options>

with the options;
template <bool B> freelist_can_allocate<B>
template <typename Alloc> allocator<Alloc>

maybe there is a better name for `freelist_can_allocate'? something like
enqueue_can_allocate_memory_from_os_if_freelist_is_exhausted? maybe a native
speaker can suggest a good and expressive name?

> 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.

i have also used boost.parameter arguments for the ringbuffer:

template <size_t element_count> ringbuffer_size<element_count>
template <typename Alloc> allocator<Alloc>

if ringbuffer_size is given, the size is specified at compile-time and the
default constructor must be used. otherwise, the ringbuffer(size_t) constructor
must be used. this is ensured via static asserts.

the allocator parameter can only be used, if the size is specified at runtime.
(again a static assert is used to ensure this).

cheers, tim




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