non incremental use of atomic_counter

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

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_examp... http://www.chaoticmind.net/%7Ehcb/projects/boost.atomic/doc/atomic/usage_exa... It should be easy to make (un-)reference and counter-operations atomic using this ;) Regards, michi7x7

michi7x7
Hi, you can easily do this using Boost.Atomic and intrusive_ptr:
http://www.chaoticmind.net/~hcb/projects/boost.atomic/doc/atomic/usage_examp...
It should be easy to make (un-)reference and counter-operations atomic using this ;)
Looks very promising. How would I increment reference count atomically by 1000? Like this? x->refcount_.fetch_add(1000, boost::memory_order_relaxed); I gather this is not Boost library yet, right? What's plan for that? Can I use it in my code? How portable is it now? Thank you Gennadiy

t I can't seem
be able to find a way to effectively/correctly implement "massive" increments with it.
Any recommendations,
My implementation (x86 and x64) has a fully general += operator. See < http://www.dlugosz.com/Repertoire/refman/Classics/atomic_counter_overview.html#toptop>. Current code for that class can be found in github under my name, John Dlugosz. --John TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
participants (3)
-
Gennadiy Rozental
-
John Dlugosz
-
michi7x7