$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Review Request: boost.lockfree
From: Tim Blechmann (tim_at_[hidden])
Date: 2009-12-14 09:54:26
hi christopher,
> I have been using this library for the past three weeks and have found
> it incredibly useful. Thank you for your excellent work, Tim!
>
> I have a pre-review question though. Is it possible to decouple
> container and the predefined wait lists so an user may use his own free
> list type? I have a use case which requires various container instances
> to share only one freelist instance, and I would like to implement this
> via an own free list type.
i reworked the freelist implementations, changing the api to:
template <typename T, bool fixed_size = false,
typename Alloc = std::allocator<T> >
class internal_freelist;
the fixed_size template argument specifies, if `allocate' may hit the os
memory allocator, when the freelist is empty. if it is set to `true',
all memory needs to be allocated in the constructor, calling the default
constructor is impossible (raises a static assertion failure).
the fifo class has a freelist_t template argument for specifying the
freelist implementation:
template <typename T, typename freelist_t =
internal_freelist<T, false, std::allocator<T> >
>
class fifo;
as a helper, a small wrapper class exists for supporting external (or
shared) freelists:
template <typename FreelistType>
class external_freelist;
with this api, you can use a shared freelist like:
typedef fifo<int>::freelist freelist; // freelist type
freelist fl(128); // shared
typedef external_freelist<freelist> freelist_wrapper;
// two fifos with, sharing the same freelist:
fifo<int, freelist_wrapper> f1(freelist_wrapper(fl));
fifo<int, freelist_wrapper> f2(freelist_wrapper(fl));
it is also possible to get a handle to the internal freelist of a fifo:
fifo<int> f(64);
typedef fifo<int>::freelist internal_freelist;
typedef external_freelist<internal_freelist> freelist_wrapper;
// use freelist of f for f2
internal_freelist & fl (f.get_freelist());
fifo<int, freelist_wrapper> f2(freelist_wrapper(fl));
the code is available from my git repository [1], branch
topic/freelist_tweaks. christopher (and others), what do you think about
this approach?
thanks, tim
[1] http://tim.klingt.org/git?p=boost_lockfree.git
-- tim_at_[hidden] http://tim.klingt.org The price an artist pays for doing what he wants is that he has to do it. William S. Burroughs