Boost logo

Boost :

Subject: Re: [boost] [lockfree] Faulty (?) static assert
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2012-09-02 14:58:46


Tim,

> >>> which implies that 'has_capacity' is allowed to be false. From what
> >>> I can see 'has_capacity' could be false, indeed, in particular if
> >>> the queue is not bounded in size.
> >>
> >> the idea is that the default constructor is only allowed, when the
> >> capacity is set at compile-time. otherwise the data structure won't
> >> be completely lockfree, as creating new nodes will hit the memory
> allocator.
> >> so the assertion is correct, but the initialization of the pool can
> >> be changed.
> >
> > Hmmm, I do not understand. If the queue is constructed with
> > fixed_size<false> (which is the default), this assertion will _always_
> > fire as you're not required to specify a capacity in this case.
>
> that's the purpose of this assertion. if the data structure is not fixed-
> sized, you should use the explicit queue(int capacity) constructor in
> order to populate the free-list.

I still don't understand why I shouldn't be allowed to default construct a
queue with fixed_size<false> and without specifying a capacity. Why do I
need to pass an initial number of nodes to the constructor in this case?

Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu


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