Boost logo

Boost Users :

Subject: Re: [Boost-users] non incremental use of atomic_counter
From: michi7x7 (mailing-lists_at_[hidden])
Date: 2010-11-19 09:33:09


Am 18.11.2010 23:02, schrieb Gennadiy Rozental:
> Hi,
>
> I've got a following problem:
>
> I need to maintain actively used shared counter in MT environment. I need usual
> increment and decrement operations with increment value of 1 plus I also need
> sometimes to operate with large increment value (like 1000, 10000).
>
> I'd like to make handling of this counter as fast as possible and would like to
> use atomic_counter used inside of boost::shared_ptr, but I can't seem be able to
> find a way to effectively/correctly implement "massive" increments with it.
>
> Any recommendations,
>
> Thank you.
>
> Gennadiy
>
Hi,

you can easily do this using Boost.Atomic and intrusive_ptr:
http://www.chaoticmind.net/~hcb/projects/boost.atomic/doc/atomic/usage_examples.html#boost_atomic.usage_examples.example_reference_counters
<http://www.chaoticmind.net/%7Ehcb/projects/boost.atomic/doc/atomic/usage_examples.html#boost_atomic.usage_examples.example_reference_counters>

It should be easy to make (un-)reference and counter-operations atomic
using this ;)

Regards,

michi7x7



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net