Boost logo

Boost :

Subject: Re: [boost] [xint] Boost.XInt formal review
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2011-03-06 20:28:50


On 3/6/2011 5:01 PM, Peter Dimov wrote:
> Chad Nelson wrote:
>
>> The only concrete complaint that people could give me about CoW was
>> that code using it couldn't be made thread-safe, which is true.
>
> Can you please provide more details? Why is not CoW thread safe?

I *can* be made thread-safe if you use atomic operations (as far as I
know; someone correct me if this I'm wrong here). However, that likely
introduces overhead even when you only need single threaded usage. If
you don't use atomic operations, then you have problems when multiple
threads try to fiddle with the reference count, leading to the potential
for dangling memory blocks and/or double deletions.

COW can introduce a performance hit with every in-place modifying
operation, as you have to ensure sole ownership (so it requires a
possible branch; you can't count the deep copying, of course, as that
would happen anyway without COW). I don't know how many operations in
*this* library fit that category, however; enough to justify the
existence of a _make_unique member function? I would also expect this
overhead to be negligible to the usual arithmetic operations once your
integers reached a certain size...

- Jeff


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